users@glassfish.java.net

Re: Persistence Problem

From: <glassfish_at_javadesktop.org>
Date: Wed, 13 Jun 2007 20:39:40 PDT

It might be because, MySQL by default will timeout the connections that are idle (not used) for 8 hours.

BTW, do you use connection pool in application server to talk to MySQL database ?
Is it GlassFish v2 ? (I guess, this problem will not be seen in GF v2 con.pools)

If you use connection pool, you can enable connection validation (table based validation) property of pool to overcome the issue.
http://blogs.sun.com/JagadishPrasath/entry/connection_validation_in_glassfish_jdbc

If you are not using connection pool,
you can set MySQL server variable "wait_timeout" to be more than 8 hours.
http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#option_mysqld_wait_timeout
OR
set the driver property "autoReconnect" to true.
http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-configuration-properties.html

Hope this helps.

Thanks,
-Jagadish
[Message sent by forum member 'jr158900' (jr158900)]

http://forums.java.net/jive/thread.jspa?messageID=222054