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 JDBC and Relational Databases 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 Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Insert in JDBC" Watch "Insert in JDBC" New topic

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.

Anselm Paulinus
Ranch Hand

Joined: Sep 05, 2003
Posts: 389
Thanks Nathaniel
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Insert in JDBC
It's not a secret anymore!