Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

escape character  RSS feed

 
Manal India
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i will to enter some addresses in my database through my java program. but the problem is that i cant enter '(single quote)...bcos there it consider ' as the end of string ...is there any escape character for SQL statements ...
please help me ..
i will bw highly obliged ..
thanks in advance ....
manal ...
 
Premkumar N
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If u want to enter say : "B'Day"
Introduce 2 more single quotes along with it: " B'''Day "
 
Manal India
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there is a problem with it ....
my data is coming dynamically ...
i have no idia what is pos of '(siingle quote) ..
 
Premkumar N
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Manal:
check for the presence of single-quotes in that dynamic-string, if it is present, replace it with '''.
Prem
 
Premkumar N
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use
myString.indexOf("'"); get the index and then replace ...
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!