I want to add a string to my sql database using JDBC. But the problem is that whenever the string contains a double quote, then the sql command is interpreted completely differently and a "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax" gets thrown."
For example, String ssql = "INSERT INTO tableName VALUES (\""+ string + "\")";
if string = "abc", then sql = INSERT INTO tableName VALUES ("abc")
But if string = "ab\"cd", then sql = INSERT INTO tableName VALUES ("ab"c")
And hence for a string that contains a double quote, the sql command is interpreted completely differently.
How can I add such a string to the database.
PS. I cannot afford to change the double quote to a single quote. And there can be other hacks to add such a string but I want to know if there really is no such way of adding such a string directly.