This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Spring and the fly likes Fetching auto-generated primary key value after insert Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Fetching auto-generated primary key value after insert " Watch "Fetching auto-generated primary key value after insert " New topic
Author

Fetching auto-generated primary key value after insert

Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3640
We are using JDBCTemplate for JDBC connectivity. Following is our insert query

insert into MyTable (Column2,Column4,Column4) values (?,?,?)

MyTable has primary key Column1 and it is a auto-generated. We need to fetch the value of Column1 after we insert record using above query.

How to achieve this?

My blood is tested +ve for Java.
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3640
I found the solution here
 
Have you checked out Aspose?
 
subject: Fetching auto-generated primary key value after insert
 
It's not a secret anymore!