setObject on PGInterval throws "Unknown Type null" - Mailing list pgsql-jdbc

From Jean-Pierre Pelletier
Subject setObject on PGInterval throws "Unknown Type null"
Date
Msg-id BAYC1-PASMTP01298C210325B348452D7995850@cez.ice
Whole thread Raw
Responses Re: setObject on PGInterval throws "Unknown Type null"  (Oliver Jowett <oliver@opencloud.com>)
List pgsql-jdbc
We upgraded to JDBC Build 309 on PostgreSQL 8.0 from
JDBC Build 307 on PostgreSQL 7.4 and setObject now fails
on PGInterval
 
1)
if myPgInterval != null
   Originally code: myPreparedStatement.setObject(i, myPGInterval)
   It throws SQLException "Unknown type null"
 
   We tried: myPreparedStatement.setObject(i, myPGInterval, Types.OTHER)
   It throws "Unknown type null"
 
if myPgInterval == null
   Original code: myPreparedStatement.setObject(i,myPGInterval)
   It throws "setObject(i,null) is not supported. Instead, use setNull(i,type) or setObject(i,null,type)"
 
   We tried: myPreparedStatement.setNull(i, Types.OTHER)
   It throws "setNull(i, Types.OTHER) is not supported; use setObject(i,null, Types.OTHER) instead"
 
   We tried: myPreparedStatement.setObject(i,myPGInterval,Types.OTHER)
   It throws "setNull(i, Types.OTHER) is not supported; use setObject(i,null, Types.OTHER) instead"
 
How should setObject be coded with a PGInterval ?
 
2)
With JDBC Build 309, setObject requires an SQL Type when object == null,
this makes setObject(i, object) useless.
 
Why do JDBC requires an SQL Type when the same statement can be processed by psql
without the SQL type specified?
 
Why is a standard JDBC method setObject(i, object) rendered useless?
Is it supported by other DBMS?
 
Thanks
Jean-Pierre Pelletier

pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: Versioned vs unversioned jarfile names?
Next
From: Oliver Jowett
Date:
Subject: Re: PGResultSetMetaData