This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC and the fly likes Retrieving auto-assigned index from inserted record Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Retrieving auto-assigned index from inserted record" Watch "Retrieving auto-assigned index from inserted record" New topic
Author

Retrieving auto-assigned index from inserted record

Ron Olson
Greenhorn

Joined: Nov 22, 2000
Posts: 14
A common database feature is the automatic assignment of a unique index for a newly inserted record (e.g. AutoNumber in MS Access). But, immediately following the insertion, how through JDBC can I retrieve that index?
What might work is to insert via ResultSet.insertRow(), and then read back the index field from that row while that ResultSet is still alive. Unfortunately, my experiments on this have been hampered because of limitations of the JDBC-ODBC bridge driver, which is a separate issue. Anyway, that technique works in other environments, like MS ADO. Does it work here? Are there other techniques that work?
 
 
subject: Retrieving auto-assigned index from inserted record