db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <fisc...@seitenbau.net>
Subject Re: Exception after my program sleep for 2 hours.
Date Wed, 11 Jun 2008 08:14:52 GMT
> >> 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.
>

Then the underlying connection pool is not configured to do this. See

http://db.apache.org/torque/releases/torque-3.3/runtime/reference/initialisation-configuration.html

For example, use.

torque.dsfactory.${databaseName}.pool.testOnBorrow=true
torque.dsfactory.${databaseName}.pool.validationQuery=SELECT 1

in your torque.properties.

    Thomas


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message