This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Batch Updates 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 "Batch Updates" Watch "Batch Updates" New topic
Author

Batch Updates

Allen Thomas
Greenhorn

Joined: Jul 02, 2002
Posts: 29
I am thinking about using Batch updates (i.e. stmt.executeBatch() ) but I am not quite understanding the advantages. I read in http://java.sun.com/docs/books/tutorial/jdbc/jdbc2dot0/batchupdates.html that " ... Sending multiple update statements to the database together as a unit can, in some situations, be much more efficient than sending each update statement separately.
My question(s) is: What do they mean "...in some situations..." batch updates would be efficient? Is there an example of where it would not be efficient to use it?
I am using the standard JDBC-ODBC driver connecting to an access database. Did anyone have any problems that I will encounter?
Thanks for your help in advance.
Allen
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Allen Thomas:
What do they mean "...in some situations..." batch updates would be efficient? Is there an example of where it would not be efficient to use it?
It is not efficient when database performance is not the bottleneck in the first place. It is not efficient when the individual updates in the batch take a long time compared to the time it takes to communicate with the database. It is very efficient when you have a whole bunch of little updates that execute very quickly individually but together take a significant time.
I am using the standard JDBC-ODBC driver connecting to an access database. Did anyone have any problems that I will encounter?
In that case I'd be tempted to say: don't bother. If you run into performance problems then your #1 optimisation would be to move away from both Access and the JDBC-ODBC bridge.
- Peter
Allen Thomas
Greenhorn

Joined: Jul 02, 2002
Posts: 29
Thanks Peter.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Batch Updates
 
Similar Threads
Database Tuning for Performance
Performance Issues with database insert !!
jdbc
stored procedure
Multiple query using servlets