Re: Problems with protocol V3 after migration to latest driver - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: Problems with protocol V3 after migration to latest driver
Date
Msg-id Pine.BSO.4.56.0410261227101.24411@leary.csoft.net
Whole thread Raw
In response to Re: Problems with protocol V3 after migration to latest driver  ("Alexey Yudichev" <Alexey@francoudi.com>)
List pgsql-jdbc

On Tue, 26 Oct 2004, Alexey Yudichev wrote:

> Ah, except that thing with "at time zone":
>
> select now() at time zone ('-02:00'::interval);
> works OK in psql console;
>
> but with JDBC
> select now() at time zone (?::interval)
> with setString(1, '-02:00')

Right, setString was recently changed from typing things as text to
varchar.  This means you need (?::text::interval) now, at least for this
example on 7.4.  Another solution would be to use the PGobject type
PGInterval via something like:

SELECT now() AT TIME ZONE ?

setObject(1, new org.postgresql.util.PGInterval("-02:00"));

I actually forget if this will work at the moment, but if not it will
eventually because of a patch from Oliver Jowett.  This avoids the pg
specific cast in your sql code, but adds pg specific code at compile time.
I imagine it might be more future proof though.

Kris Jurka

pgsql-jdbc by date:

Previous
From: Kris Jurka
Date:
Subject: Re: Problems with protocol V3 after migration to latest driver
Next
From: "Jason Tesser"
Date:
Subject: using 8 bit ascii