aspose file tools*
The moose likes JDBC and the fly likes getGeneratedKeys() + batchUpdate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "getGeneratedKeys() + batchUpdate" Watch "getGeneratedKeys() + batchUpdate" New topic
Author

getGeneratedKeys() + batchUpdate

C.P Sanchalanam
Greenhorn

Joined: Aug 05, 2006
Posts: 15
Hello there,

Is it allowed to use getGeneratedKeys() on PreparedStatement to get all the generated unique IDs (seq.nextval) generated in a batch update? please advice.

If it is not allowed please could you suggest a method to retrieve sequence Ids from a batch update.

Here is the requirement:

I have 2 tables DataTable1 (columns: ID, Name) and DataTable2 (REF-ID, value) and the relationship between these table is one-to-many:

I am using an batch insert into DataTable1 to add multiple rows and each row's ID is unique and it is generated by seq.nextval. Now, after this batch insert I need to retrieve all the generated IDs and use these IDs to inser data into the second table(DataTable2).


Thanks for your help.

Sanchi
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

"Sanchi Sanchi",
Please check your private messages regarding an important administrative matter.
-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
C.P Sanchalanam
Greenhorn

Joined: Aug 05, 2006
Posts: 15
Hello All, I would appreciate any views or suggesting on this. Hoping to hear from someone.

Thanks,
Sanchi
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

You would need to try it. My guess is that it would be vendor specific and would either return the generated keys, or would throw an Exception when called from the PreparedStatement
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getGeneratedKeys() + batchUpdate
 
Similar Threads
DAO class design
Spring Batch for reading file and checking data in database
Batch consisting of multiple PreparedStatements
Inserting Files to Database.
building a dataTable from java code