Re: Problem escaping, nonstandard use of \\ in a string literal

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Warren Bell <warren(at)clarksnutrition(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Problem escaping, nonstandard use of \\ in a string literal
Date: 2008-08-19 01:01:48
Message-ID: 48AA1B7C.6040705@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Albe Laurenz 2008-08-19 06:42:10 Re: Problem escaping, nonstandard use of \\ in a string literal
Previous Message Warren Bell 2008-08-19 00:36:25 Re: Problem escaping, nonstandard use of \\ in a string literal