commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vijay Anjur" <vijay.an...@gmail.com>
Subject commons dbcp connection pool not releasing connections
Date Fri, 31 Mar 2006 21:04:39 GMT
Sorry for sending multiple emails, I was not sure if my previous email went
through.

Hi,

I found that my physical connections never being closed...  My code below:

private static void setupDataSourceConnectionPool()

   {

      try

      {

private static InitialContext ic = null;

            private static Context envCtx = null;

            private static DataSource dsMyDb;

            private static ObjectPool poolMyDb;

            private static PoolingDataSource pdsMyDb;

            private static BasicDataSource bdsMyDb;



         dsMyDb = (DataSource) envCtx.lookup("ds/MyDbServer");



         if (dsMyDb != null)

         {

           bdsMyDb = (BasicDataSource)dsINTLDB;



/*I am doing this because it keeps getting its default values in
GenericObjectPool */

           poolINTLDB = new GenericObjectPool(null,
bdsMyDb.getMaxActive(),(byte)1,
bdsMyDb.getMaxWait(),bdsMyDb.getMaxIdle(), bdsMyDb.getMinIdle(),
bdsMyDb.getTestOnBorrow(),


dsMyDb.getTestOnReturn(), bdsMyDb.getTimeBetweenEvictionRunsMillis(),
bdsMyDb.getNumTestsPerEvictionRun(), bdsMyDb.getMinEvictableIdleTimeMillis(),



bdsMyDb.getTestWhileIdle());

            ConnectionFactory cf1 = new DataSourceConnectionFactory(dsMyDb);

            PoolableConnectionFactory pcf1 = new
PoolableConnectionFactory(cf1, poolMyDb, null, null, false, true);

            pcf1.setValidationQuery(bdsMyDb.getValidationQuery());

            pdsMyDb = new PoolingDataSource(poolMyDb);

         }

}



My JNDI- properties in server.xml is:

<Resource

      name="jdbc/intldbServer"

      auth="Container"

      type="javax.sql.DataSource"

      factory="org.apache.commons.dbcp.BasicDataSourceFactory"

      driverClassName="net.sourceforge.jtds.jdbc.Driver"

      validationQuery="Select 1"

      maxWait="6000"

      username="JAVAappserver"

      password="JAVAappserver"

      testOnBorrow="true"

      testOnReturn="true"

      testWhileIdle="true"

      url="jdbc:jtds:sqlserver://MyDbServer:16000"

      initialSize="5"

      numTestsPerEvictionRun="10"

      timeBetweenEvictionRunsMillis="100000"

      minEvictableIdleTimeMillis="80000"

      removeAbandoned="false"

      removeAbandonedTimeout="120"

      logAbandoned="true"

      maxActive="20"

      maxIdle="5"

      minIdle="0"/>



I tried debugging through sourcecode, I found that an exception (shown
below) happens when destroyobject is called and that it is ignored.

java.sql.SQLException: Already closed.

        at org.apache.commons.dbcp.PoolableConnection.close(
PoolableConnection.java:77)

        at
org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(
PoolingDataSource.java:180)

        at org.apache.commons.dbcp.DelegatingConnection.close(
DelegatingConnection.java:151)

        at org.apache.commons.dbcp.PoolableConnection.reallyClose(
PoolableConnection.java:95)

        at org.apache.commons.dbcp.PoolableConnectionFactory.destroyObject(
PoolableConnectionFactory.java:301)

        at beehive.service.go.sql.GenericObjectPool.evict(
GenericObjectPool.java:1027)

        at beehive.service.go.sql.GenericObjectPool$Evictor.run(
GenericObjectPool.java:1125)

        at java.util.TimerThread.mainLoop(Timer.java:512)

        at java.util.TimerThread.run(Timer.java:462)



But I am calling close only once!  Can someone help please???

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message