aspose file tools
The moose likes JDBC and the fly likes MySQL Connector/J: autoReconnectForPools Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply 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
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: MySQL Connector/J: autoReconnectForPools
 
Similar Threads
Read time out error
Strange exception when trying to make remote method call...
Problem faced in using the Java Mail Api
java.rmi.UnmarshalException: (RMIunder Linux)
Enable Mailing services