title: JTDS and JBOSS JDBC Connection Pool Problem, any solution? Maybe a custom ValidConnectionChecker?
body: <p>I'm facing a weird production problem. Environment is the following:</p>
  
  <ul>
  <li>JBOSS 4.0.2 </li>
  <li>SQL Server 2005 </li>
  <li>Driver JTDS 1.2.5</li>
  </ul>
  
  <p>From time to time the following szenario occurs.</p>
  
  <p>A SQL command fails to Excute with</p>
  
  <pre><code> java.sql.SQLException: I/O Error: Read timed out 
  </code></pre>
  
  <p>(I can live with that, if it just happens twice a day or so)</p>
  
  <p>But from that moment on the connection seems to be wasted without the pool recognizing it, as I continously receive</p>
  
  <pre><code>java.sql.SQLException: Invalid state, the Connection object is closed.
  </code></pre>
  
  <p>from that moment on. The only thing that helps is restarting JBOSS. This occurs despite of the fact that I have </p>
  
  <pre><code> &lt;check-valid-connection-sql&gt;select getdate()&lt;/check-valid-connection-sql&gt;
  </code></pre>
  
  <p>set up in my Datasource definition.</p>
  
  <p>I was wondering if I can use a custom ValidConnectionChecker, that either rebuilds the connection itself, or explicitly throws a Exception to fix this. Maybe anyone has other suggestions.</p>
  
  <p>Here is my complete DS definition.</p>
  
  <pre><code>  &lt;local-tx-datasource&gt;
      &lt;jndi-name&gt;MyDS&lt;/jndi-name&gt;
      &lt;connection-url&gt;jdbc:jtds:sqlserver://192.168.35.235:1433/MyDb;user=user1;password=pwd;appName=MyApp;loginTimeout=15;socketTimeout=120&lt;/connection-url&gt;
      &lt;driver-class&gt;net.sourceforge.jtds.jdbc.Driver&lt;/driver-class&gt;
      &lt;user-name&gt;user1&lt;/user-name&gt;
      &lt;password&gt;pwd&lt;/password&gt;
      &lt;min-pool-size&gt;10&lt;/min-pool-size&gt;
      &lt;max-pool-size&gt;25&lt;/max-pool-size&gt;
      &lt;blocking-timeout-millis&gt;60000&lt;/blocking-timeout-millis&gt;
      &lt;idle-timeout-minutes&gt;1&lt;/idle-timeout-minutes&gt;
      &lt;check-valid-connection-sql&gt;select getdate()&lt;/check-valid-connection-sql&gt;
    &lt;/local-tx-datasource&gt;
  </code></pre>
  
  <p></p>
  
  <p>Any help appriciated.</p>
  
  <p>Regards</p>