Postgresql JDBC-Driver

Started by Rudolpho Gian-Franco Gugliottaalmost 22 years ago3 messages
#1Rudolpho Gian-Franco Gugliotta
rudolpho@gugliotta.org

Hi,

i'm using the jdbc postgresql driver. I need to fetch the oid of a just
insertet row
(getGeneratedKeys() feature). That' why i ask you to provide me the
source code
to implement this feature.It would be glad if you tell me how and where
to get
these sources.

Thank you very much,

Rudolpho Gugliotta

#2Kris Jurka
books@ejurka.com
In reply to: Rudolpho Gian-Franco Gugliotta (#1)
Re: Postgresql JDBC-Driver

On Fri, 5 Mar 2004, Rudolpho Gian-Franco Gugliotta wrote:

Hi,

i'm using the jdbc postgresql driver. I need to fetch the oid of a just
insertet row
(getGeneratedKeys() feature). That' why i ask you to provide me the
source code
to implement this feature.It would be glad if you tell me how and where
to get
these sources.

The driver source is included in the main source tree for the 7.4 series,
but for the upcoming 7.5 release the driver is being developed
independently here:
http://gborg.postgresql.org/project/pgjdbc/projdisplay.php

Some discussion of the problems with implementing getGeneratedKeys is
here:
http://archives.postgresql.org/pgsql-jdbc/2003-12/threads.php#00193

Finally you don't necessarily need to implement getGeneratedKeys if you
don't mind using some pg specific code along the lines of the following:

Statement stmt = conn.createStatement();
stmt.executeUpdate("INSERT INTO t VALUES (1)");
long oid = ((org.postgresql.PGStatement)stmt).getLastOID();

Kris Jurka

#3Dave Cramer
pg@fastcrypt.com
In reply to: Rudolpho Gian-Franco Gugliotta (#1)
Re: Postgresql JDBC-Driver

This is not a viable solution, as oid's are not guaranteed to be unique,
nor are they primary keys; finally tables can be created without oid's,
in fact AFAIK, this will be the default in 7.5.

Dave
On Fri, 2004-03-05 at 08:25, Rudolpho Gian-Franco Gugliotta wrote:

Hi,

i'm using the jdbc postgresql driver. I need to fetch the oid of a just
insertet row
(getGeneratedKeys() feature). That' why i ask you to provide me the
source code
to implement this feature.It would be glad if you tell me how and where
to get
these sources.

Thank you very much,

Rudolpho Gugliotta

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

!DSPAM:40c8fe6b9391076077350!

--
Dave Cramer
519 939 0336
ICQ # 14675561