commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Holly" <>
Subject RE: [DBCP] How to kill connection pool when app is reloaded.
Date Tue, 01 Jul 2003 20:00:05 GMT
Thanks to Tony for the help.  I created a ContextListener and this works...

In my application I actually have to access two datasources.  In my
development env
both data sources reside on the same DB but access different schemas via
userids.  In my production the data sources are seperate oracle instances.

In the ContextIntialized method the two datasources seem to register just


When the ContextListener destroys I am going through and trying to remove
the pool
for both datasources.  Am I correct in believing that since it looks like I
configure two different pools as jndi resources in the context.xml that I
have two different pools?  Or do I have one pool that stores all the
different connections?

I find that if I execute the code to remove the second data source

         if (ds2 instanceof org.apache.commons.dbcp.BasicDataSource) {
  "Found oracle_talisen connection pool " +
ds2.toString() );
            ((org.apache.commons.dbcp.BasicDataSource) ds2).close();
            ds2 = null;

I get a null pointer exception.  This I can understand if connections are
stored in one pool.  To confirm this I added the ds2.toString() in the log.
This confirmed that the objects that ds1 and ds2 are located in the same
place in memory.

However, the head scratcher here is that the connections for the second
datasource do not go away even though it appears that I have killed the

Any ideas?



-----Original Message-----
From: Tony Locke []
Sent: Saturday, June 28, 2003 8:40 AM
To: Jakarta Commons Users List;
Subject: Re: [DBCP] How to kill connection pool when app is reloaded.

Hi Michael,

I had this problem and I solved it by putting:

if (ds instanceof org.apache.commons.dbcp.BasicDataSource) {
    ((org.apache.commons.dbcp.BasicDataSource) ds).close();

in the contextDestroyed method of the context listener class of my web



On Thu, 26 Jun 2003, Michael Holly wrote:

> Hi
> I need to kill my connection pool when I reload the application.
> I am using Tomcat 4.1.24, Oracle 8.1.7, Win 2k, Java 1.3.1
> I have configured my ant script to deploy my application without
> restarting Tomcat.
> Server.xml has no application context information in it.
> context.xml contains the context for the application
> I was under the false assumption that the
> pool was an application resource and would be reset when the application
> got reloaded.   In testing yesterday I got an Oracle error about too many
> processes.  I did some digging and found that every time I redeployed
> the application the previous connection pool was staying alive.
> Is there a way to kill the pool?  I have a startup servlet that handles
> initiation of log4j and caching services.  I should be able to put the
> code to kill the pool in the destroy method of this servlet.
> Thanks
> Michael
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Tony Locke                

View raw message