java - c3p0 reconnect after network outage -


the application connects ms sql server. uses c3p0 combopooleddatasource in tomcat , spring environment.

when application loses database connection , gets few seconds later, application recovers connection , can continue querying db (as network back). network outage longer, application needs more 10 minutes recover db connection after network came back.

i see these logs when db connection after 10 minutes:

[warning] exception on close of inner statement.java.sql.sqlexception: invalid state, connection object closed. @ net.sourceforge.jtds.jdbc.tdscore.checkopen(tdscore.java:481)      [warning] [c3p0] pooledconnection has signalled connection error still in use!  [warning] [c3p0] error has occurred [ java.sql.sqlexception: invalid state, connection object closed. ] not reported listeners!java.sql.sqlexception: invalid state, connection object closed. 

here spring-config.xml configuration:

<bean id="commondatasource" abstract="true" class="com.mchange.v2.c3p0.combopooleddatasource" destroy-method="close">     <property name="driverclass" value="net.sourceforge.jtds.jdbc.driver" />     <property name="minpoolsize" value="${db.minpoolsize}" />     <property name="maxpoolsize" value="${db.maxpoolsize}" />     <property name="acquireretryattempts" value="0" />     <property name="checkouttimeout" value="0" />     <property name="testconnectiononcheckout" value="true" />     <property name="testconnectiononcheckin" value="false" />     <property name="idleconnectiontestperiod" value="10" />     <property name="preferredtestquery" value="select 1" /> </bean> 

i tried other configurations, non-zero checkouttimeout, testconnectiononcheckout=false , testconnectiononcheckin=true, recovery still long.

what wrong configuration? recover db connection network issues fixed.

many

edit hakari configuration suggested m. deinum

hi,

i tried hakari configuration:

<bean id="commondatasource" abstract="true" class="com.zaxxer.hikari.hikaridatasource" destroy-method="close">     <property name="maximumpoolsize" value="${db.maxpoolsize}" />     <property name="connectiontestquery" value="select 1"/>     <property name="allowpoolsuspension" value="true"/> </bean> 

but behaviour similar: have wait 10-15 minutes before getting database connection back.

would have suggestion please?

the issue not related c3p0 nor hikaricp. had modify jdbc url , add these properties:

logintimeout=60;sockettimeout=60 

maybe 1 enough job both of these. link helps lot http://jtds.sourceforge.net/faq.html


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -