wood burning stoves 2.0*
The moose likes JDBC and the fly likes Insert in JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Insert in JDBC" Watch "Insert in JDBC" New topic
Author

Insert in JDBC

Anselm Paulinus
Ranch Hand

Joined: Sep 05, 2003
Posts: 389
An interview question I had recently, given about 100,000 records to insert in a persistent storage using JDBC; What is the most efficient way of doing this. Would I have to call commit 100,000 times to do this?
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
Well, using a procedure that is compiled by your SQL server is one step. Using the JDBC batch method is a good step, too. As for the commit, that would depend on whether it is called for or not. If the inserts are all truly atomic, then yes--each commit needs to be called. (See the batch method for specifics though). If they all need to be completely inserted, or none, then the commit would only need to be called once.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Anselm Paulinus
Ranch Hand

Joined: Sep 05, 2003
Posts: 389
Thanks Nathaniel
 
 
subject: Insert in JDBC
 
Similar Threads
Limiting the Fetch Size
Add batch (batch insertion into the database)
Using JDBC versus Stored Procedures
singleton class
jdbc