Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

quoting strings in JDBC

Status
Not open for further replies.

carpeliam

Programmer
Mar 17, 2000
990
US
I know most languages have a quote() function somewhere in their DB classes that replaces the ' or " characters with the appropriate quoted characters, so that these characters do not throw off the quotes in the SQL string. I have yet to figure out whether java supports the same thing. How do you quote characters in Java? Liam Morley
lmorley@wpi.edu
"light the deep, and bring silence to the world.
light the world, and bring depth to the silence."
 
what you have to do is use the \ character
example:

String sql = "select * from table where id = \"thisid\""

this will set the string to equal

select * from table where id = "thisid"

 
that's not exactly what I had in mind... for example, in Perl, the DBI package has the quote() function which will replace any quote inside of a string with the appropriate quoted string. <p>Liam Morley<br><A HREF="mailto:"></A><br>&quot;light the deep, and bring silence to the world.<br>light the world, and bring depth to the silence.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top