my dog learned polymorphism*
The moose likes JDBC and the fly likes batch updating mysql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "batch updating mysql" Watch "batch updating mysql" New topic
Author

batch updating mysql

mat buckland
Greenhorn

Joined: Sep 01, 2009
Posts: 24
I have a Container of objects in my server, which regularly need writing to the database. At the moment I simply iterate through the container and do an executeUpdate() for each object.

This is slow though. Is there a way I can create an update that will send all the objects to the database in one cumulative update instead of many?

thanks
mat buckland
Greenhorn

Joined: Sep 01, 2009
Posts: 24
tis ok, i've found the answer!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38003
    
  22
Well done

For the benefit of future generations searching this forum, how did you do it?
mat buckland
Greenhorn

Joined: Sep 01, 2009
Posts: 24
good point!

Like this:

http://www.java2s.com/Code/Java/Database-SQL-JDBC/BatchupdateforMySQL.htm
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38003
    
  22
It's nice when you can find links like that, isn't it
 
wood burning stoves
 
subject: batch updating mysql
 
Similar Threads
Unwanted SELECTs on session flush (HIBERNATE Wrong)
Singleton versus Static class?
Access Intent
EJB vs Java Beans--design choice
distributable