Re: apostrophe problem for a preparedstatement
Posted by: Mark Matthews
Date: January 11, 2005 08:57AM

C Leung wrote:
> 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();


Your code works fine for test1 for me, you don't need to escape them as in test2 and test3, and I can't believe that you actually get this code to compile, as test2 is a syntax error (\' is not a valid character sequence for a string in Java) :(

What character set is your database set to?


Mark Matthews
Consulting Member Technical Staff - MySQL Enterprise Tools

Options: ReplyQuote

Written By
Re: apostrophe problem for a preparedstatement
January 11, 2005 08:57AM

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.