commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harald <harald-nos...@gmxpro.de>
Subject [DBCP] SharedPoolDataSource and numActive
Date Thu, 01 Dec 2005 16:37:01 GMT
Hi,

I use SharedPoolDataSource:

ConnectionPoolDataSource datasource ; 
    :
SharedPoolDataSource poolDataSource = new SharedPoolDataSource();
poolDataSource.setConnectionPoolDataSource(datasource);
poolDataSource.setMaxActive(maxActive);
poolDataSource.setMaxIdle(maxIdle);
poolDataSource.setValidationQuery(validationQuery);
poolDataSource.setTestOnBorrow(true); 
poolDataSource.setTestOnReturn(true);
poolDataSource.setTestWhileIdle(true);


(1) Now I get a Connection via 
      Connection conn = poolDataSource.getConnection();

(2) use the connection and

(3) close the connection with 
       conn.close();

The pool work correctly.

Now a error occurre and the connection is invalid. 

Subject to action it call the method
        public void connectionClosed(ConnectionEvent event)
or
        public void connectionErrorOccurred(ConnectionEvent event)

(both define in 
org.apache.commons.dbcp.datasources;KeyedCPDSConnectionFactory)

connectionClosed(..) try to put the connection into pool with
_pool.returnObject(..)

It this failed so called
        destroyObject(info.getUserPassKey(), info);

Also connectionErrorOccurred(..) invoke
        destroyObject(info.getUserPassKey(), info);

In this cases numActive from the pool isn't decrease. 

I think it would be best to replace 
        destroyObject(info.getUserPassKey(), info);
by
       _pool.invalidateObject(info.getUserPassKey(), info); 

It this correct?

--
Harald








---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message