You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Poitras Christian <Ch...@ircm.qc.ca> on 2006/05/11 19:19:58 UTC

RE: autoReconnect=true doesn't solve closed connection problem

iBatis automatically handle reconnection to databse on connection
failure.
 
To use this possibiliy, user can define a certain number of variables in
your sqlmapconfig.
 
Here is an example.
<transactionManager type="JDBC">

<dataSource type="SIMPLE">

<property value="${driver}" name="JDBC.Driver"/>

<property value="${url}" name="JDBC.ConnectionURL"/>

<property value="${username}" name="JDBC.Username"/>

<property value="${password}" name="JDBC.Password"/>

<property value="${pingquery}" name="Pool.PingQuery"/>

<property value="${pingenable}" name="Pool.PingEnabled"/>

<property value="${pingoldertime}"
name="Pool.PingConnectionsOlderThan"/>

</dataSource>

</transactionManager>

 
 
Make sure the property files contains all the properties specified. I
use.

driver=com.mysql.jdbc.Driver

url=jdbc:mysql://localhost:3306/data

username=root

password=

pingquery=SELECT 1

pingenable=true

pingoldertime=2000

 


________________________________

From: Tony Qian [mailto:daqiqian2@aol.com] 
Sent: Thursday, 11 May 2006 12:22
To: user-java@ibatis.apache.org
Subject: autoReconnect=true doesn't solve closed connection problem


All,

I set following in SglMapConfig.xml file:

 <property name="JDBC.ConnectionURL"
value="jdbc:mysql://hostName:3306/dbName?autoReconnect=true"/>

It doesn't solve Communication Failure problem due to closed connection.
Setting autoReconnection=true works when connection pool is managed by
Tomcat (DBCP). (btw, PingQuery solves the problem)

database is MySql 5.019, JDBC diver is mysql-connector-java-3.1.11.

Did I do something wrong? any suggestion?

thanks,
Tony