Re: Inserting an Interval Using JDBC

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: dba(at)vilaj(dot)com
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Inserting an Interval Using JDBC
Date: 2006-01-23 20:10:13
Message-ID: 43D53825.10107@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Will Szopko wrote:

> I have just upgraded to the 8.1-404 version of the JDBC driver from a
> much older version. In the past I had been able load an interval into my
> database by sending it as a string, as such:
>
> String myInterval = "08:00"; // 8 hour interval
> ...
> stmt.setString(1, myInterval);
>
> Using the new driver I am no longer able to do this and get the
> following error:
>
> column "num_hours" is of type interval but expression is of type text

Use "CAST (? AS INTERVAL)" in your query, or use the custom
org.postgresql.util.PGInterval type and pass an instance to setObject().

-O

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Will Szopko 2006-01-23 20:19:24 Re: Inserting an Interval Using JDBC
Previous Message balpo (sent by Nabble.com) 2006-01-23 19:22:32 Re: RFP: Finish JDBC driver