Comments - How to escape backslash in an insert statement

10 years ago Vladislav Vaintroub
This comment has the status of 'removed' and can only be seen by you.

second variation is correct. I'm not sure about syntax errors you get, but to get single backslash you need to escape it twice, once with java, and again in SQL, which results in 4 backslashes. ´ I verified that unit test below succeeds

@Test public void escaping() throws Exception { Statement st = connection.createStatement(); ResultSet rs = st.executeQuery("select '

'");; assertEquals("
", rs.getString(1)); }

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.