You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Barney Hamish <Ha...@ect-telecoms.de> on 2002/08/29 16:22:24 UTC

DBCP Problems

Hi,
Just started using DBCP(1.0) to do my DB connection pooling but have two
problems:
The connection keeps dropping out. I keep recieving SQL exceptions saying
the connection is closed, sometimes in the middle of retrieving my query
results.
eg.
java.sql.SQLException: Connection is closed.


I decided to put in some debugging code when I establish the connection.

PoolingDriver poolingDriver = (PoolingDriver)
DriverManager.getDriver(defDbURL);
ObjectPool objectPool = poolingDriver.getPool("/sql_databases");
System.out.println("Active - " + objectPool.getNumActive() + " Idle - " +
objectPool.getNumIdle());

but that gives me a negative number of active connections(eg. see below)
Active - -5 Idle - 0

The number of active connections seems to decrease every time I request a
new one.

Find below my configuration file for DBCP. Has anyone encountered similar
problems or know what I'm doing wrong?

Thanks,
Hamish

<object class="org.apache.commons.dbcp.PoolableConnectionFactory"
xmlns="http://apache.org/xml/xmlns/jakarta/commons/jocl">
	<object
class="org.apache.commons.dbcp.DriverManagerConnectionFactory">
		<!--DB Connection String-->
      		<string
value="jdbc:inetdae7://XXXXXXX:1433?database=sql_databases"/>

      		<!--DB Connection Properties-->
		<object class="java.util.Properties" null="true"/>
   	</object>

	<object class="org.apache.commons.pool.impl.GenericObjectPool">
		<!--Factory object-->
		<object
class="org.apache.commons.pool.PoolableObjectFactory" null="true"/>

		<!--Max Active Connections-->
		<int value="20"/>

		<!--When Exhausted Action-->
		<byte value="1"/><!--Blocks when the pool is exhausted-->

		<!--Max Wait--> 
		<long value="2000"/>

		<!--Max Idle-->
		<int value="-15"/>

		<!--Test On Borrow-->
		<boolean value="true"/>

		<!--Test on Return-->
		<boolean value="true"/>

		<!--time Between Eviction Runs (Millis)-->
		<long value="10000"/>

		<!--Number of test per eviction run-->
		<int value="5"/>

		<!--Minimum evictable idle time (Millis)-->
		<long value="5000"/>

		<!--Test when idle-->
		<boolean value="true"/>
	</object>
		
	<object
class="org.apache.commons.pool.impl.GenericKeyedObjectPoolFactory">
		<!--Factory object-->
		<object
class="org.apache.commons.pool.KeyedPoolableObjectFactory" null="true"/>

		<!--Max Active Connections-->
		<int value="5"/>

		<!--When Exhausted Action-->
		<byte value="1"/>

		<!--Max Wait--> 
		<long value="2000"/>

		<!--Max Idle-->
		<int value="5"/>

		<!--Test On Borrow-->
		<boolean value="true"/>

		<!--Test on Return-->
		<boolean value="true"/>
	
		<!--time Between Eviction Runs (Millis)-->
		<long value="10000"/>

		<!--Number of test per eviction run-->
		<int value="5"/>

		<!--Minimum evictable idle time (Millis)-->
		<long value="5000"/>

		<!--Test when idle-->
		<boolean value="true"/>
	</object>
	
	<!--Validation query-->
	<string value="SELECT getDate()"/>

	<!--Default read-only-->
	<boolean value="false"/>

	<!--Default AutoCommit-->
	<boolean value="true"/>
</object>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>