File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using generatedKeys() with PostGRESQL

 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Madhan Sundararajan Devaki
Ranch Hand
Posts: 312
Java MS IE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Madhan!
Thanks for the reply .
Can you /anyone suggest any postgresql drivers that support the same?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic