[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Re: mysql connection reset

trunikov do-not-reply at jboss.com
Sat Dec 15 02:28:06 EST 2007

Hi tomerbd2!
Below is a fragment from J/Connector manual about parameter autoReconnect :
anonymous wrote : Should the driver try to re-establish stale and/or dead connections? If enabled the driver will throw an exception for a queries issued on a stale or dead connection, which belong to the current transaction, but will attempt reconnect before the next query issued on the connection in a new transaction. The use of this feature is not recommended, because it has side effects related to session state and data consistency when applications don't handle SQLExceptions properly, and is only designed to be used when you are unable to configure your application to handle SQLExceptions resulting from dead and stale connections properly. Alternatively, investigate setting the MySQL server variable "wait_timeout" to some high value rather than the default of 8 hours.
As stated use parameter autoReconnect is a bad practice. I think you should tune value of a tag idle-timeout-minutes in your data source descriptor. A description/example of how to do that is here.
Also tags check-valid-connection-sql and new-connection-sql could be useful.
Below is an example of a data source descriptor:

		<check-valid-connection-sql>select 1</check-valid-connection-sql>
		<new-connection-sql>select 1</new-connection-sql>

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4113124#4113124

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4113124

More information about the jboss-user mailing list