Updating a database periodically with Java

Posted by MSR on Stack Overflow See other posts from Stack Overflow or by MSR
Published on 2011-01-08T12:41:00Z Indexed on 2011/01/08 12:53 UTC
Read the original article Hit count: 135

Filed under:

I would like to perform updates to a MySQL database using two separate classes (that do different things) -- one doing so every 10 seconds, and the second every minute. I have a few gaps in my Java knowledge and I'm wondering what the best way to achieve it is.

Importantly, if connectivity to the database is lost, I need reconnection attempts to occur indefinitely, and I'm guessing the use of Prepared Statements will make queries more efficient. Should the connection to the database be left open all the time or closed between the updates being run? Maybe I also need to think about clearing objects/resources out of memory if the class instances are going to be run indefinitely.

© Stack Overflow or respective owner

Related posts about java