File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Java for batch db update.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Java for batch db update.." Watch "Java for batch db update.." New topic

Java for batch db update..

Maky Chopra
Ranch Hand

Joined: Apr 11, 2001
Posts: 149
Hi Folks,
I need to do a batch update of db field (thanks for help with the SQL statement for this)..
I have a

and for the main() program, I have

Now, when i cann UpdateExpDate() for every record in the i/p file, it needs to make a connection.. I know this can be very expensive in terms of resources.. One way is that I can setup a connection pool class and use connections from that. Other than that, what can I do to batch process this i/p file ?
Thanks in advance for any help you can provide..
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

have a connection as a class variable.

one connection/prepared statement per object created.

[This message has been edited by Jamie Robertson (edited September 13, 2001).]
Maky Chopra
Ranch Hand

Joined: Apr 11, 2001
Posts: 149
Thanks Jamie !! Just moving the conn to my constructor cut down the time to load 100000 records (in a P-III 800Mhx NT machine with mySQL db) from 3 minutes to 43seconds
Will try the batching tomorrow and see if there's any dramatic improvement ... Thanks again.
I agree. Here's the link:
subject: Java for batch db update..
It's not a secret anymore!