Re: Problem with PGStatement.getLastOID()

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: ListMan <listman(at)cybermaccara(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Problem with PGStatement.getLastOID()
Date: 2003-12-01 23:25:28
Message-ID: 20031201232528.GA19205@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Tue, Dec 02, 2003 at 12:50:26AM +0200, ListMan wrote:
> Hi!
>
> I hope you can help me with a problem with the jdbc-driver devel version
> (need it for 7.4).
>
> With driver version pg73jdbc the following works fine:
>
> int rowCount = -1;
> long insertedOid = -1;
> Connection con = null;
> Statement stmt = null;
>
> con = sec.getConnection(); // gets pooled connection
> stmt = con.createStatement();
> con.setAutoCommit(false);
> rowCount = stmt.executeUpdate(query);
> con.commit();
> insertedOid = ((org.postgresql.PGStatement)stmt).getLastOID();
> con.setAutoCommit(true);
> con.close();
>
> With devel version I get ClassCastException on row with insertedOid =
> ((org.postgresql.PGStatement)stmt).getLastOID();
>
> Version 73 drivers were tested against our production server which is
> running postgres 7.3 and devel drivers were tested against my own own
> machine running 7.4 on Cygwin.

Your comment above implies you're using a connection pool; is it possible
that you're actually getting a wrapper Connection/Statement implemented by
the pool infrastructure, rather than the Connection/Statement objects handed
out by the driver directly? What is the concrete class of 'stmt' reported in
the ClassCastException?

Alternatively it may be a classloading difference between the two machines
-- the cast will fail if your code and the JDBC code use versions of
org.postgresql.PGStatement loaded by different classloaders.

Either way, it sounds like the two environments differ by more than just
driver versions. Try the 7.3 drivers you use in production on your Cygwin
box (against a 7.3 server if necessary) and see if you get the same failure.

-O

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2003-12-01 23:37:03 Re: Problem with PGStatement.getLastOID()
Previous Message ListMan 2003-12-01 22:50:26 Problem with PGStatement.getLastOID()