Hi all! I'm using DBCP with Spring, Hibernate, and MySQL and running into reconnection issues. Basically, all is fine and good for a few days and then sudden the connection pool fails to connect to the database. This is becoming a real embarasment because our app keeps going down even though nothing in the app is wrong. I'm reasonably sure it's a network hiccup or a database restart that triggers the problem but we can't seem to get it fixed. I'd expect the pool to re-establish the connection but after 3 tries it gives up and no where in the documentation can I see a way to increase that (or ideally never give up at all). As it stands, I've enabled every setting I can to make it just hammer the connections into submission but we always fail for the same reason. I've included the settings and the exception below. Any help would be greatly appreciated!

DBCP Settings

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" abstract="false" singleton="true" lazy-init="default" autowire="default" dependency-check="default">
   <property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://*****:3306/*****?autoReconnect=true&autoReconnectForPools=true&initialTimeout=1" />
    <property name="username" value="*****" />
   <property name="password" value="*****" />
   <property name="initialSize" value="5" />
   <property name="maxIdle" value="5" />
   <property name="maxActive" value="20" />
   <property name="validationQuery" value="select 0" />
   <property name="testWhileIdle" value="true" />
   <property name="testOnBorrow" value="true" />
   <property name="timeBetweenEvictionRunsMillis" value="30000" />
   <property name="numTestsPerEvictionRun" value="10" />
   <property name="minEvictableIdleTimeMillis" value="60000" />
</bean>

Exception - This occurs for every connection in the pool and once we see it, all hope is lost for it never recovers:

2006/12/01 05:38:19.274 SEVERE [13]
(JDBCExceptionReporter.logExceptions): Server connection failure during transaction. Due to underlying exception: 'java.net.SocketException: java.net.ConnectException: Connection refused'.

** BEGIN NESTED EXCEPTION **

java.net.SocketException
MESSAGE: java.net.ConnectException: Connection refused

STACKTRACE:

java.net.SocketException: java.net.ConnectException: Connection refused
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:284)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2690)
at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266) at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:37) at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:290) at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:840) at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:95) at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540) at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:80) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:417) at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144) at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:93) at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:86) at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:171) at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2163) at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118) at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374) at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:91)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:394) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366) at org.springframework.orm.hibernate3.HibernateTemplate.update(HibernateTemplate.java:655) at org.springframework.orm.hibernate3.HibernateTemplate.update(HibernateTemplate.java:651)
at com.***.trivia.loadbalancer.LobbyDao.updateLobby(LobbyDao.java:73)
at com.***.trivia.loadbalancer.LobbyDao.saveLobby(LobbyDao.java:21)
at com.***.trivia.loadbalancer.LoadBalancerPlugin.scanRooms(LoadBalancerPlugin.java:79) at com.***.trivia.loadbalancer.LoadBalancerPlugin$RoomScanTimerTask.run(LoadBalancerPlugin.java:132)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)


** END NESTED EXCEPTION **

Attempted reconnect 3 times. Giving up.


Michael Grundvig
Electrotank, Inc
http://www.electrotank.com


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to