Skip site navigation (1) Skip section navigation (2)

setObject type for Interval objects

From: David Goodenough <david(dot)goodenough(at)btconnect(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: setObject type for Interval objects
Date: 2007-06-28 09:58:17
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
I have an SQL SELECT which contains an expressions of the form:-


where created is a TIMESTAMP field.  As a parameter I want to pass 
an interval, so I used:-

PGInterval interval = new PGInterval( intervalPeriod);
stmt.setObject( 1, interval);

but Postgresql objects with:-

org.postgresql.util.PSQLException: Can't infer the SQL type to use for an 
instance of org.postgresql.util.PGInterval. Use setObject() with an explicit 
Types value to specify the type to use.

So I guess I need the three parameter setObject, but I do not know what
type to pass to the third parameter.  I have googled, but to no avail (I 
obviously asked the wrong question).



pgsql-jdbc by date

Next:From: Albe LaurenzDate: 2007-06-28 13:00:28
Subject: Re: setObject type for Interval objects
Previous:From: Edoardo PanfiliDate: 2007-06-28 08:53:25
Subject: Re: error: operator does not exist: bigint = character varying

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group