This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Best way to insert 10000 rows in JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Best way to insert 10000 rows in JDBC" Watch "Best way to insert 10000 rows in JDBC" New topic
Author

Best way to insert 10000 rows in JDBC

Senthil Kumar Sekar
Ranch Hand

Joined: Aug 08, 2010
Posts: 45

Hi All,
Can anyone tel me the best way to perform 10000 rows insert or bulk insert in JDBC?
Say,I have a file with 10k records which i need to insert to DB after manipulation.

Thanks.

Regards
Senthil Kumar Sekar
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

There are two alternatives:
1) prepared statement batch updates (in smaller groups)
2) writing to a flat file and importing at command line

I'd probably go with #1 because I would want to batch the manipulation of the 10K records anyway.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
xsunil kumar
Ranch Hand

Joined: Dec 14, 2009
Posts: 133
Use Batch update for this
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1624
    
  13

If you're using Oracle and can provide your data in a CSV file, then using Oracle external tables is probably the quickest way to do this.


No more Blub for me, thank you, Vicar.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Best way to insert 10000 rows in JDBC
 
Similar Threads
Best practice to access large data from database
To load a huge records from a DB to a JTable
error while inserting data using poi
Update or Insert
JDBC addBatch problem