Re: apostrophe problem for a preparedstatement
Posted by: C Leung
Date: January 06, 2005 09:05PM

Mark,

Here's the simple piece of code i used for testing.

String test1 = "123'456'789";
String test2 = "123\'456\'789";
String test3 = "123\\'456\\'789";

String sql = "UPDATE table1 SET field1=?";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setString(1,test1);
pstmt.executeUpdate();


I have tried test1, test2 and test3, all didn't work. Table1 already have records in it.

The error message i receive is like that:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '456\\'789' ' at line 1"

See the 2 back slashes it added for me for the second apostrophe? I tried typing 2 slashes in command prompt for the same query, it will return error.

Please help and thanks!

Chap

Options: ReplyQuote


Subject
Written By
Posted
Re: apostrophe problem for a preparedstatement
January 06, 2005 09:05PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.