-
1. Re: How to Auto-Reconnect jtds on DB restart
thunder.farmer Sep 12, 2010 9:03 PM (in response to jboden)As far as I know, the check-valid-connection-sql will do the trick for you. I verified this on both mysql and informix server.
I believe your problem lies in spring beans which is cached and hence has no chance to get the newly created connection from JBoss.
I would suggest that you change your datasource bean to "prototype" to try and verify my guess.
Also you need to config ALL the beans which refer to datasource bean to be "prototype".
BTW, configurating the datasource to be a "prototype" bean is not best practice.
If you verified that my guess turn out to be true, you need to find sulotion from spring side and not JBoss side.
Regards,
Thunder
-
2. Re: How to Auto-Reconnect jtds on DB restart
hughbragg Oct 6, 2010 3:16 AM (in response to thunder.farmer)Connection.isValid() isn't implemented in jtds.
I'm not using jboss, but I found even catching any SQLException and forcing a complete restart of the connection didn't work.
-
3. Re: How to Auto-Reconnect jtds on DB restart
vgarmash Apr 15, 2011 2:40 PM (in response to jboden)You can try to disable caching of your JNDI datasource in Spring like this:
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName"><value>java:/MSSQLDS</value></property>
<property name="cache" value="false" />
<property name="proxyInterface" value="javax.sql.DataSource" />
</bean>
Here is a quote from JndiObjectFactoryBean:
/**
* Set whether to cache the JNDI object once it has been located.
* Default is "true".
* <p>Can be turned off to allow for hot redeployment of JNDI objects.
* In this case, the JNDI object will be fetched for each invocation.
* <p>For hot redeployment, a proxy interface needs to be specified.
* @see #setProxyInterface
* @see #setLookupOnStartup
*/