Thread: error: ResultSet.updateObject(timestamp in POSTGRES, DATE(7) in ORACLE )

error: ResultSet.updateObject(timestamp in POSTGRES, DATE(7) in ORACLE )

From
"Vidas Makauskas"
Date:
Hi,
I've upgrade SLES9 with pg73b1jdbc3.jar to SLES10 with
postgresql-8.1-404.jdbc3.jar

ResultSet.updateObject(timestamp in POSTGRES, DATE(7) from ORACLE database
via OJDBC13.JAR )
begin produce error in ResultSet.insertRow():
Exception in thread "main" java.lang.ClassCastException
        at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRowBuffer(AbstractJdbc2ResultSet.java:1727)
        at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.insertRow(AbstractJdbc2ResultSet.java:832)
.........

CAST ( TRUNC ( ORACLE->DATE(7), 'DD' ) AS TIMESTAMP ) in ORACLE view not
accetable too.

There's no errors in case ResultSet.updateObject(date in POSTGRES, DATE(7)
from ORACLE)
Vidas



Re: error: ResultSet.updateObject(timestamp in POSTGRES,

From
Kris Jurka
Date:

On Mon, 28 Aug 2006, Vidas Makauskas wrote:

> I've upgrade SLES9 with pg73b1jdbc3.jar to SLES10 with
> postgresql-8.1-404.jdbc3.jar
>
> ResultSet.updateObject(timestamp in POSTGRES, DATE(7) from ORACLE database
> via OJDBC13.JAR )
> begin produce error in ResultSet.insertRow():
> Exception in thread "main" java.lang.ClassCastException
>        at
> org.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRowBuffer(AbstractJdbc2ResultSet.java:1727)
>        at
> org.postgresql.jdbc2.AbstractJdbc2ResultSet.insertRow(AbstractJdbc2ResultSet.java:832)
> .........
>

I can reproduce this using only postgresql by trying to copy a date field
to a timestamp field.  The issue is that the updatable result set code
assumes that if the target is a timestamp then the incoming object will
also be a timestamp and it may safely cast that object to a
java.sql.Timestamp.  This is not always so as shown, so the driver needs
some more powerful conversion utilities here, something along the lines of
PreparedStatement.setObject(index, obj, targetType) would do the trick.
This is a low priority item for me, so I won't be working on this anytime
soon, but here's the test case I used.

Kris Jurka

Attachment