How to escape backslash in an insert statement

I am using the MariaDB JDBC driver 1.1.1 and trying to insert string literal with "\" to a table. How do I escape it? I tried the following and was getting syntax errors.

1) String stmt = "insert into test (name, value) values ('c$', 'c:\\')"; 

2) String stmt = "insert into test (name, value) values ('c$', 'c:\\\\')"; 

Thanks!

Manju

Answer Answered by Vladislav Vaintroub in this comment.

Your second variant is correct.

I can run it without any errors (assuming I have table test with varchar(10) columns "name " and "value"), and it produces the correct result with single backslash character.

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.