This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes JDBC and the fly likes Insert with ' Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Insert with Watch "Insert with New topic
Author

Insert with '

Mike Yu
Ranch Hand

Joined: Nov 17, 2001
Posts: 175
Hi,
How can I insert a string with ' into a table in DB2?


Thanks,<br />Mike
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Originally posted by Mike Yu:
Hi,
How can I insert a string with ' into a table in DB2?

Use a PreparedStatement ( setString() method ) and it will take care of it for you. If you need to use a statement you have to create a routine that escapes it with the DB2 escape character. Assuming it is 2 single quotes, this routine would work for you:

Jamie
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Insert with '
 
Similar Threads
Approach for "Say", part a
Transaction management
Game on SQL
JSP and Access
XML, flat files to database