Re: Problem with PGStatement.getLastOID()

Поиск
Список
Период
Сортировка
От Oliver Jowett
Тема Re: Problem with PGStatement.getLastOID()
Дата
Msg-id 20031201232528.GA19205@opencloud.com
обсуждение исходный текст
Ответ на Problem with PGStatement.getLastOID()  (ListMan <listman@cybermaccara.com>)
Ответы Re: Problem with PGStatement.getLastOID()  (ListMan <listman@cybermaccara.com>)
Список 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

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: ListMan
Дата:
Сообщение: Problem with PGStatement.getLastOID()
Следующее
От: Dave Cramer
Дата:
Сообщение: Re: Problem with PGStatement.getLastOID()