You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Paul Tomsic <pt...@yahoo.com> on 2004/03/26 02:14:52 UTC

DBCP abandoned connections piling up, never clearing, reaching max_connections

Tomcat 4.1.30, MySql 4.0.18-standard, dbcp-1.1,mysql
jdbc 3.0.9

We're using mysql on a different box than the tomcat.
The problem we're having is, when we deploy to the box
using ant, and watch the mysql process list, 5-7
connections start immediately and stay "sleeping" for
ever.  Then, every time we make a connection to the DB
from within the application, it's not being cleaned
up.  So, new connections are made all the time, and
never cleaned up, not to mention that the initial 5 or
so that are started when the app is deployed stay
sleeping forever.  Within a brief period of heavy
activity, we have to stop everything, b/c we're out of
connections.

We have a class that handles the pool, w/ a private
instance constructor and the following:

DriverAdapterCPDS cpds = new DriverAdapterCPDS();
SharedPoolDataSource tds = new SharedPoolDataSource();
cpds.setDriver(dbDriver);
cpds.setUrl(dbUri);
cpds.setUser(dbUser);
cpds.setPassword(dbPass);
tds.setConnectionPoolDataSource(cpds);
tds.setMaxActive(0);
tds.setMaxWait(50);
tds.setTimeBetweenEvictionRunsMillis(20);
DataSource ds = tds;

Then there's a method that simply returns
ds.getConnection() from within that singleton pool
class.
When we get a connection, it's wrapped in a
try/catch/finally where inside the finally we
conn.close() explicitly.

Sorry to be long, but anyone have any thoughts?

thanks in advance.




__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

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


Re: DBCP abandoned connections piling up, never clearing, reaching max_connections

Posted by Dirk Verbeeck <di...@pandora.be>.
What exactly do you mean with "sleeping", is that a mysql connection 
state or something?

Your approach of having a connection pool in a singleton is fine, no 
obvious problems with it.

Can you post a testcase that fails? Or the relevant parts of your 
code. (but make sure is is complete and easily runnable, in tomcat or 
as junit test)

-- Dirk

Paul Tomsic wrote:

> Tomcat 4.1.30, MySql 4.0.18-standard, dbcp-1.1,mysql
> jdbc 3.0.9
> 
> We're using mysql on a different box than the tomcat.
> The problem we're having is, when we deploy to the box
> using ant, and watch the mysql process list, 5-7
> connections start immediately and stay "sleeping" for
> ever.  Then, every time we make a connection to the DB
> from within the application, it's not being cleaned
> up.  So, new connections are made all the time, and
> never cleaned up, not to mention that the initial 5 or
> so that are started when the app is deployed stay
> sleeping forever.  Within a brief period of heavy
> activity, we have to stop everything, b/c we're out of
> connections.
> 
> We have a class that handles the pool, w/ a private
> instance constructor and the following:
> 
> DriverAdapterCPDS cpds = new DriverAdapterCPDS();
> SharedPoolDataSource tds = new SharedPoolDataSource();
> cpds.setDriver(dbDriver);
> cpds.setUrl(dbUri);
> cpds.setUser(dbUser);
> cpds.setPassword(dbPass);
> tds.setConnectionPoolDataSource(cpds);
> tds.setMaxActive(0);
> tds.setMaxWait(50);
> tds.setTimeBetweenEvictionRunsMillis(20);
> DataSource ds = tds;
> 
> Then there's a method that simply returns
> ds.getConnection() from within that singleton pool
> class.
> When we get a connection, it's wrapped in a
> try/catch/finally where inside the finally we
> conn.close() explicitly.
> 
> Sorry to be long, but anyone have any thoughts?
> 
> thanks in advance.




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


RE: DBCP abandoned connections piling up, never clearing, reaching max_connections

Posted by "G. Madhan Dennis" <ma...@isoftel.com>.
Hi,

Are you closing all the result sets and statements that you use before
closing the connection?

Regards,
Madhan

-----Original Message-----
From: Paul Tomsic [mailto:ptomsic@yahoo.com] 
Sent: Friday, March 26, 2004 6:45 AM
To: commons-user@jakarta.apache.org
Subject: DBCP abandoned connections piling up, never clearing, reaching
max_connections


Tomcat 4.1.30, MySql 4.0.18-standard, dbcp-1.1,mysql
jdbc 3.0.9

We're using mysql on a different box than the tomcat.
The problem we're having is, when we deploy to the box
using ant, and watch the mysql process list, 5-7
connections start immediately and stay "sleeping" for
ever.  Then, every time we make a connection to the DB
from within the application, it's not being cleaned
up.  So, new connections are made all the time, and
never cleaned up, not to mention that the initial 5 or
so that are started when the app is deployed stay
sleeping forever.  Within a brief period of heavy
activity, we have to stop everything, b/c we're out of connections.

We have a class that handles the pool, w/ a private
instance constructor and the following:

DriverAdapterCPDS cpds = new DriverAdapterCPDS(); SharedPoolDataSource
tds = new SharedPoolDataSource(); cpds.setDriver(dbDriver);
cpds.setUrl(dbUri); cpds.setUser(dbUser); cpds.setPassword(dbPass);
tds.setConnectionPoolDataSource(cpds);
tds.setMaxActive(0);
tds.setMaxWait(50);
tds.setTimeBetweenEvictionRunsMillis(20);
DataSource ds = tds;

Then there's a method that simply returns
ds.getConnection() from within that singleton pool
class.
When we get a connection, it's wrapped in a
try/catch/finally where inside the finally we
conn.close() explicitly.

Sorry to be long, but anyone have any thoughts?

thanks in advance.




__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

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


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


RE: DBCP abandoned connections piling up, never clearing, reaching max_connections

Posted by Daniel Huang <da...@cisco.com>.
I think it will be easier if you can config your DBCP as a JNDI resource.
Check out
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-how
to.html

Thanks
Daniel

-----Original Message-----
From: Paul Tomsic [mailto:ptomsic@yahoo.com]
Sent: Thursday, March 25, 2004 5:15 PM
To: commons-user@jakarta.apache.org
Subject: DBCP abandoned connections piling up, never clearing, reaching
max_connections

Tomcat 4.1.30, MySql 4.0.18-standard, dbcp-1.1,mysql
jdbc 3.0.9

We're using mysql on a different box than the tomcat.
The problem we're having is, when we deploy to the box
using ant, and watch the mysql process list, 5-7
connections start immediately and stay "sleeping" for
ever.  Then, every time we make a connection to the DB
from within the application, it's not being cleaned
up.  So, new connections are made all the time, and
never cleaned up, not to mention that the initial 5 or
so that are started when the app is deployed stay
sleeping forever.  Within a brief period of heavy
activity, we have to stop everything, b/c we're out of
connections.

We have a class that handles the pool, w/ a private
instance constructor and the following:

DriverAdapterCPDS cpds = new DriverAdapterCPDS();
SharedPoolDataSource tds = new SharedPoolDataSource();
cpds.setDriver(dbDriver);
cpds.setUrl(dbUri);
cpds.setUser(dbUser);
cpds.setPassword(dbPass);
tds.setConnectionPoolDataSource(cpds);
tds.setMaxActive(0);
tds.setMaxWait(50);
tds.setTimeBetweenEvictionRunsMillis(20);
DataSource ds = tds;

Then there's a method that simply returns
ds.getConnection() from within that singleton pool
class.
When we get a connection, it's wrapped in a
try/catch/finally where inside the finally we
conn.close() explicitly.

Sorry to be long, but anyone have any thoughts?

thanks in advance.




__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

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


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