Inserting String into a database that contains the single quote character

From: Joe Ray (raymis_at_hotmail.com)
Date: 07/15/04


Date: 15 Jul 2004 14:47:46 -0700

Hi,

I am trying to insert String data into a MySQL database. However the
data contains single quotes in it.

   con.executeUpdate("INSERT INTO DB VALUES("It's a crappy day")");

which gives me an SQL Syntax error. So what I did is to use a regular
expression to go through my text to replace ' with \'. I search for
"\'" and replace with "\\\'". However, that doesn't do any difference.
Any clues or different ways to attack this problem. Thanx

Joe



Relevant Pages