wood burning stoves 2.0*
The moose likes JDBC and the fly likes MySQL Connector/J: autoReconnectForPools Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MySQL Connector/J: autoReconnectForPools" Watch "MySQL Connector/J: autoReconnectForPools" New topic
Author

MySQL Connector/J: autoReconnectForPools

Brian R. Wainwright
Ranch Hand

Joined: Aug 12, 2003
Posts: 92
Does anyone know if the "autoReconnectForPools" parameter for the org.gjt.mm.mysql.Driver is what I need to use to resolve stale connections to the database throwing:

because MySQL closes connections after 8 hours of inactivity? My specific implementation, just as an FYI (although I'm not sure if its totally relevant) is I'm using Hibernate as a persistence layer and their DBCPConnectionPool implementation.
Thanks!
--BW
Wayne L Johnson
Ranch Hand

Joined: Sep 03, 2003
Posts: 399
I've used DBCP with Oracle and I ran into a similar problem. The fix was to specify a "validQuery" parameter (something simple and quick) that the underlying connection pool would use to validate the query before handing it back. Since then my app has been running (2 months and counting) w/out any problem.
I have used hibernate a bit in connection with Tomcat and JNDI, and I believe you can define the DataSource to include a "validQuery" parameter. Hopefully it will solve your problem.
Brian R. Wainwright
Ranch Hand

Joined: Aug 12, 2003
Posts: 92
Thanks Wayne. You are indeed correct. For MySQL a valid validQuery would be something like: "select 1" - for anyone listenign in hibernate you can specify this in the connection pool thusly:

--BW
 
 
subject: MySQL Connector/J: autoReconnectForPools
 
Similar Threads
Enable Mailing services
Strange exception when trying to make remote method call...
Problem faced in using the Java Mail Api
Read time out error
java.rmi.UnmarshalException: (RMIunder Linux)