aspose file tools*
The moose likes JDBC and the fly likes Using generatedKeys() with PostGRESQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Using generatedKeys() with PostGRESQL " Watch "Using generatedKeys() with PostGRESQL " New topic
Author

Using generatedKeys() with PostGRESQL

Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Hi Folks,
I was trying to use the generatedKeys() method of PreparedStatement to get the autoincrementing primary key of my resultset in an insert query .However it threw a PSQL exception stating --
org.postgresql.util.PSQLException: This method is not yet implemented.


Is there a workaround or another method to implement it through the same query as we do in the case of generatedkeys()? I'm aware of using currval and nextval,any other methods that somebody could suggest?
Thanks.


Learning and Learning!-- Java all the way!
Madhan Sundararajan Devaki
Ranch Hand

Joined: Mar 18, 2011
Posts: 312

I believe, generatedKeys() method will be implemented by the JDBC drive you use to connect to a Database.
In case of Oracle this is implemented, however, for PostGreSQL I am not sure whether this is implemented.
Please check if this is the case and try getting a driver for PostGreSQL that supports this feature, otherwise you may need to write custom code to generate the next key.


S.D. MADHAN
Not many get the right opportunity !
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Hi Madhan!
Thanks for the reply .
Can you /anyone suggest any postgresql drivers that support the same?
 
Don't get me started about those stupid light bulbs.
 
subject: Using generatedKeys() with PostGRESQL