title: Connections do not return to the pool (JBoss EAP 6 AND SQL Server 2012)
body: <p>I have an application running under jboss eap 6.3 and connecting to a SQL SERVER 2012 datasource through jTDS driver. The problem is the connections are opened and never return to the pool.</p>
  
  <p>at first, there are no CONNECTION LEAK. I have already configured jboss to investigate this using the configuration below:</p>
  
  <pre><code>&lt;cached-connection-manager debug="true" error="true"/&gt;
  </code></pre>
  
  <p>Jboss found out one connection leak (in one statement) and i fixed it, but the problem remains.</p>
  
  <p>the database configuration is as follows:</p>
  
  <pre><code>&lt;datasource jta="false" jndi-name="java:jboss/datasources/DatabaseDS" pool-name="DatabaseDS" enabled="true" use-java-context="true" use-ccm="true"&gt;
  &lt;connection-url&gt;jdbc:jtds:sqlserver://server/database;instance=instance;DatabaseName=database&lt;/connection-url&gt;
  &lt;driver&gt;jtds&lt;/driver&gt;
  &lt;pool&gt;
      &lt;min-pool-size&gt;200&lt;/min-pool-size&gt;
      &lt;max-pool-size&gt;1200&lt;/max-pool-size&gt;
      &lt;prefill&gt;true&lt;/prefill&gt;
  &lt;/pool&gt;
  &lt;security&gt;
      &lt;user-name&gt;username&lt;/user-name&gt;
      &lt;password&gt;password&lt;/password&gt;
  &lt;/security&gt;
  &lt;timeout&gt;
      &lt;blocking-timeout-millis&gt;30000&lt;/blocking-timeout-millis&gt;
      &lt;idle-timeout-minutes&gt;1&lt;/idle-timeout-minutes&gt;
  &lt;/timeout&gt;
  </code></pre>
  
  <p></p>
  
  <p>after one day in production, the statistics of jboss-cli show the following data:</p>
  
  <p><a href="https://i.stack.imgur.com/a7bou.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a7bou.png" alt="enter image description here"></a></p>
  
  <p>"In use" score, is always the same size as the "Count Active" . This number does not make sense to me, because for every request made, we open and close only one connection and at the time the print was made, had 98 sessions connected to jboss.</p>
  
  <p>investigating the SQL Server processes for this application ( master.dbo.sysprocesses ) all "active count" connections are with "AWAITING COMMAND" status and detailed as "sleeping"</p>
  
  <p>I am 100 % sure that all connections that are open are also closed in the application.</p>
  
  <p><strong>in about 2 days the pool is 100 % completed and need to restart the server</strong></p>
  
  <p>what may be causing this behavior ?
  the value of "active count" should not be 200 ?
  which may be blocking connections to return to the pool ?</p>