Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

MySql strippes java's two backslashes

807589Aug 24 2008 — edited Aug 25 2008
I have a common task, though can't figure out the problem with backslashes.

MySql table "MyTable" records pathes to files in the column "path_file".

In java:
String filename = "c:\temp\infile.txt";
filename.replaceAll("\\\\", "\\\\\\\\\\\\\\\\"));   

String sql = "UPDATE MyTable SET path_file ='" + filename + "' WHERE File =" + File_ID;
stmt.executeUpdate(sql);
Java results in: c:\\\\temp\\\\infile.txt
MySql strippes all backslashes: c:tempinfile.txt

When directly working with Mysql MyTable in Mysql:

UPDATE MyTable SET path_file = "c:\\temp\\infile.txt" WHERE File = 1;

MySql MyTable records the correct result: c:\temp\infile.txt

Any idea?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 22 2008
Added on Aug 24 2008
7 comments
291 views