Thomas Fischer wrote:
I have a java program that uses Torque and it is working fine with
one exception. My program might need to sleep for 2 hours, using
Thread.sleep() but after it wake up again, torque always throws an
exception when I try to call doSelect(). Is there anyway to avoid
this?. This program don't do any connection handling at all.
The exception indicates that this is a mysql problem. please search the net
for this mysql problem.
Well, as far as I can see, the problem is that torque reuse the same
mysql connection for all its queries.
This is in itself a good thing, because it would be a waste to open a
new connection each time it perform a query,
but when I put the application to sleep, the connection times out
because it is not used in 2 hours.
But torque don't detect that the connection is timed out, and then it
get this mysql error, when it tries to use the timed out connection.
As far as I can see there are 2 possible solutions: Either torque should
detect that the connection is closed, and then
open a new connection, or I should tell torque to close the connection
before I call Thread.sleep and then tell
torque to reopen the connection after the program wake up. But I could
not find any api calls to do this.
Martin