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
Date Tue, 07 Mar 2006 23:02:33 GMT
 Application connects to database.Pool has 5 connections.
Exit the application.Kill all the 5 connections (the Pool has) in the
database.
Try connecting to the database from the application, I get the following
error:
 org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool
exhausted
        at org.apache.commons.dbcp.PoolingDataSource.getConnection(
PoolingDataSource.java:103)
        at org.apache.commons.dbcp.BasicDataSource.getConnection(
BasicDataSource.java:540)
        at
org.apache.commons.dbcp.DataSourceConnectionFactory.createConnection(
DataSourceConnectionFactory.java:42)
        at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(
PoolableConnectionFactory.java:290)
        at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(
GenericObjectPool.java:771)
        at org.apache.commons.dbcp.PoolingDataSource.getConnection(
PoolingDataSource.java:95)
I have set maxActive to 7. and testOnBorrow to true.
 Public void setupPool(){
private static PoolingDataSource pdsSample
DataSource dsSample = (DataSource) envCtx.lookup("ds/sample");
ConnectionFactory cf1 = new DataSourceConnectionFactory(dsSample);
poolSample = new GenericObjectPool(null,

                                               bdsINTLDB.getMaxActive(),

                                               (byte)1,

                                               bdsINTLDB.getMaxWait(),

                                               bdsINTLDB.getMaxIdle(),

                                               bdsINTLDB.getMinIdle(),

                                               bdsINTLDB.getTestOnBorrow(),

                                               bdsINTLDB.getTestOnReturn(),


bdsINTLDB.getTimeBetweenEvictionRunsMillis(),


bdsINTLDB.getNumTestsPerEvictionRun(),


bdsINTLDB.getMinEvictableIdleTimeMillis(),

                                               bdsINTLDB.getTestWhileIdle()
);
 PoolableConnectionFactory pcf1 = new PoolableConnectionFactory(cf1,
poolSample, null, null, false, true);
pcf1.setValidationQuery(bdsINTLDB.getValidationQuery());
pdsSample = new PoolingDataSource(poolSample);

}



public Connection getConnection(){
try{
Connection c = pdsSample.getConnection();

}catch(Exception e)

return c;
}

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