Re: Getting oid after insert

From: Barry Lind <blind(at)xythos(dot)com>
To: Zak McGregor <zak(at)mighty(dot)co(dot)za>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Getting oid after insert
Date: 2003-08-28 05:18:48
Message-ID: 3F4D90B8.70400@xythos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Zak,

What version are you working with? The code example below won't work
with the latest versions of the driver (either 7.3 or 7.4). In the
latest versions you cast your Statement object to a
org.postgresql.PGStatement object and call getLastOID() which returns
the oid as a long.

thanks,
--Barry

Zak McGregor wrote:
> Hi all
>
> I am struggling to get the following code bit to work. It is supposed to be part
> of getting the oid of the last insert. Can anyone see what I'm doing wrong
> please? (Apart from using Java I mean....)
>
> Thanks
> Statement stmt=conn.createStatement();
> stmt.executeUpdate(sqlStatement);
> org.postgresql.ResultSet result =
> (org.postgresql.ResultSet)stmt.getResultSet();
> String statusString =result.getStatusString();
> System.out.println( "Status string returned: "+statusString );
>
> I get the following error:
>
> ***Exception:
> java.lang.NullPointerException
> java.lang.NullPointerException
> at celerity.DBase.executeSQL(DBase.java:82)
> at DBTest.main(DBTest.java:16)
>
>
> it does compile fine. Removing all the above lines and leaving just this:
> Statement stmt=conn.createStatement();
> stmt.executeUpdate(sqlStatement);
>
> inserts the rows fine.
>
>
> Thanks
>
> Ciao
>
> Zak
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Uday Walia 2003-08-28 07:41:29 pg 7.3 Time function not working
Previous Message Barry Lind 2003-08-28 05:11:45 Re: FATAL: Socket command type A unknown