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();
Chap,
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
Mark Matthews
Consulting Member Technical Staff - MySQL Enterprise Tools
Oracle
http://www.mysql.com/products/enterprise/monitor.html