I have tried using some of your settings, leaving out the validation test string and even tried closing a connection more than once. But I can't get the number of active connections to go negative.

PoolableConnection.close() checks if it has been closed before (_closed=true). If it has it throws an exception, otherwise it returns itself to the pool. So it doesn't look like closing more than once can lead to this problem.

Looking at the code I have seen only 1 way (so far) to get a negative number of active connections. It involves GenericObjectPool.invalidateObject().

If you call this twice (or more) with the same object eg
connectionPool.invalidateObject(conn);
connectionPool.invalidateObject(conn);

Then each time numActive will be decremented. In fact, you can call it with null eg connectionPool.invalidateObject(null), and it will also decrement the numActive.

It looks like it is used when you have a connection (or object) you know is bad eg threw an exception, and don't want it returned to the object pool.

It looks like you aren't using this from the code snippets you have shown, so it could be some other problem.

Jason Lea

[EMAIL PROTECTED] wrote:
It's almost as if every time i call close it decrements, but nothing ever increments it?

Could it be this problem that Jason stated below?

Travis

---- Original Message ----
From: Jason Lea <[EMAIL PROTECTED]>
Sent: 2003-04-01
To: Jakarta Commons Users List <[EMAIL PROTECTED]>
Subject: Re: [DBCP] Strange Problems and Errors

[EMAIL PROTECTED] wrote:

Ok, I'm getting some strange behaviour with dbcp as detailed below:

Here is the config for it:

connectionPool = new GenericObjectPool(null); connectionPool.setMaxActive(50); connectionPool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW); connectionPool.setMaxIdle(50); connectionPool.setNumTestsPerEvictionRun(5); connectionPool.setTestWhileIdle(true); connectionPool.setTimeBetweenEvictionRunsMillis(20000); connectionPool.setTestOnBorrow(true); connectionPool.setTestOnReturn(false); connectionPool.setMinEvictableIdleTimeMillis(-1);

DriverManagerConnectionFactory connectionFactory = new DriverManagerConnectionFactory(dbUrl, props); PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,connectionPool,null,null,false,true); pool = new PoolingDataSource(connectionPool);


Not sure if this will fix the problem but I noticed you are not supplying a validationQuery when you create the PoolableConnectionFactory. As you are testing the connection while idle and testOnBorrow is also true, the pool should be running a test eg

PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,connectionPool,null,"SELECT test FROM testtable",false,true);



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to