| Author |
double quotes in java
|
Amod Mulay
Ranch Hand
Joined: Apr 06, 2006
Posts: 33
|
|
while passing values from a jsp to a servlet if i am passing a double quote by replacing it with it's ascii value and further pass it through to a query ...obviously the resultant is wrong.....tried to search through SQL help but haven't been able to breake this problem... EG: Select * from xya table where name="Am""od"; well one of our clients has entries in his database ..... interisting HAN!!! So does anyone know how i can tackle this problem
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
|
This definitely is not on the SCJP exam, so I'm moving it to the JSP forum.
|
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14685
|
|
Is this really a JSP question ?  Anyway, did you try to use single quotation in your SQL ? where name='Am""od';
|
[My Blog]
All roads lead to JavaRanch
|
 |
Amod Mulay
Ranch Hand
Joined: Apr 06, 2006
Posts: 33
|
|
well i do not know how to change my forum from SCJP to any other that i want...but deff. this not a jsp question... and yes i have tried doing that but it does not work that way.......
|
 |
Stefan Evans
Bartender
Joined: Jul 06, 2005
Posts: 1008
|
|
Use prepared statements. That will escape any nasty characters in the data for you, and you don't have to worry about sql injection attacks.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56533
|
|
|
Moved to the JDBC forum.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
 |
|
|
subject: double quotes in java
|
|
|