Re: Problem escaping, nonstandard use of \\ in a string literal - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: Problem escaping, nonstandard use of \\ in a string literal
Date
Msg-id 48AA1B7C.6040705@opencloud.com
Whole thread Raw
In response to Re: Problem escaping, nonstandard use of \\ in a string literal  (Warren Bell <warren@clarksnutrition.com>)
List pgsql-jdbc
Warren Bell wrote:

> I ended up going back to PostgreSQL version 8.1. I did not have the time
> to work everything out.
>
> I am using Ibatis and the prepared statement that was being used was
> something like:
>
> INSERT INTO tabel (somestringfield) VALUES (?)
>
> the parameter that was passed was 'Joe\'s'. I also tried  E'Joe\'s'. It
> did not like the escaped apostrophe. I guess Postgres 8.3 is escaping
> special characters differently. It seems like this would be something
> the driver would handle. How are you suppose to make this work? I will
> also check with the Ibatis group on this.

This should "just work" with no quoting and no escaping of the string
that you pass to setString(). i.e. you should just be doing:

   ps.setString(1, "Joe's");

If you've managed to get escaping/quoting errors somehow I'd really like
to know how .. the parameter is passed out-of-line from the query
string, not interpolated into it, so I'm really puzzled how this could
ever happen.

A testcase would be great.

-O

pgsql-jdbc by date:

Previous
From: Warren Bell
Date:
Subject: Re: Problem escaping, nonstandard use of \\ in a string literal
Next
From: "Albe Laurenz"
Date:
Subject: Re: Problem escaping, nonstandard use of \\ in a string literal