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

From: Kris Jurka <books(at)ejurka(dot)com>
To: Vidas Makauskas <vms(at)centras(dot)lt>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: error: ResultSet.updateObject(timestamp in POSTGRES,
Date: 2006-08-30 02:47:08
Message-ID: Pine.BSO.4.63.0608292135190.28706@leary2.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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 Content-Type Size
UpdateTypeTest.java text/plain 1.1 KB

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2006-08-30 02:56:28 Re: Could not determine data type of parameter $1
Previous Message Kris Jurka 2006-08-30 00:47:13 Re: outOfMemoryError