aspose file tools*
The moose likes JDBC 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
Bookmark "double quotes in java" Watch "double quotes in java" New topic
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: 14688
    
  16

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: 1018
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: 61648
    
  67

Moved to the JDBC forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: double quotes in java