[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:


	<local-tx-datasource>
		<jndi-name>xxxDS</jndi-name>
		<connection-url>jdbc:mysql://127.0.0.1:3306/xxx</connection-url>
		<driver-class>com.mysql.jdbc.Driver</driver-class>
		<user-name>xxx</user-name>
		yyy
		
			<type-mapping>MySQL</type-mapping>
		
		<min-pool-size>5</min-pool-size>
		<max-pool-size>20</max-pool-size>
		<idle-timeout-minutes>10</idle-timeout-minutes>
		<check-valid-connection-sql>select 1</check-valid-connection-sql>
		<new-connection-sql>select 1</new-connection-sql>
		<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
		<valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
	</local-tx-datasource>




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