| From: | "Eamon Reyn" <eamonreyn(at)clear(dot)net(dot)nz> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Java Strings and quote marks |
| Date: | 2003-11-26 06:41:37 |
| Message-ID: | 3fc44b4d@clear.net.nz |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hi I am trying to do an insert query but for some reason although there
appears to be no exception thrown my data does not get into the database.
I will try to explain what I am doing
In SQL you can do the following sort of statement
INSERT INTO mytable (fname, lname, age) VALUES ('Joe', 'Bloggs', 20);
I realise this is not a java newsgroup but please forgive my use of java
specific syntax below.
I am trying to replicate this in Java by doing this
String query = "INSERT INTO mytable (fname, lname, age) VALUES ";
query = query + " ('" + method call that returns a string + "', '"
query = query + method call that returns a string + "', "
query = query + method call that returns an int + ");"
executeUpdate(query);
as far as I am concerned this should equate to the same thing as I wrote in
the first instance, but when I inspect the contents of the literal query it
appears as
INSERT INTO mytable (fname, lname, age) VALUES (\'Joe\', \'Bloggs\', 20);
^^^^^^^^^^^^^^^
Inserts backslashes
Is this why my Update is not working and if so what do I need to do.
Thanks in advance,
Eamon.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2003-11-26 07:53:14 | Re: TIMEZONE not working? |
| Previous Message | cnliou | 2003-11-26 06:14:05 | TIMEZONE not working? |