File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes double quotes in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "double quotes in java" Watch "double quotes in java" New topic

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

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
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

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

Joined: Jul 06, 2005
Posts: 1580
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

Joined: Jan 10, 2002
Posts: 63852

Moved to the JDBC forum.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: double quotes in java
It's not a secret anymore!