commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tony Locke <tlo...@tlocke.org.uk>
Subject Re: [DBCP] Pool shut down when Tomcat context removed
Date Sat, 21 Jun 2003 19:57:12 GMT
Thanks for this Stephen. In the end I opted for the following bit of code:

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

It has the disadvantage that it's tied to the DBCP implementation, but
this doesn't matter too much because it's only needed for testing. On the
other hand the garbage collecting option has the disadvantage that there
are no guarantees about when or even if the objects will be garbage
collected.

Cheers,

Tony.

On Sat, 21 Jun 2003, Stephen Westbom wrote:

> Yes, make sure that the classes are loaded by the application's class loader,
> not any of the server ones so that they go out of scope and are eligible for
> garbage collection when you remove an application (or undeploy).
>
> Follow this link to get a better understanding of applications and class
> loaders in general within Tomcat.
>
> http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-howto.html
>
> This means deploying the jar files for DBCP in the war file for the
> application. Is this is really what you want to do (not share connections
> between applications at the server level)?
>
> Have fun
>
> --- Tony Locke <tlocke@tlocke.org.uk> wrote:
> > Hi,
> >
> > I have a similar problem to that described in a previous post. I'm using
> > DBCP as a JNDI datasource in Tomcat 4.1.24. As part of a test script I
> > need to restore a database, but I can only do that once all the
> > connections to the db are closed. I hoped that doing a 'remove' on the
> > Tomcat web application would close down all the connections in the pool,
> > but this doesn't seem to happen.
> >
> > I configure the datasource in server.xml, but I've tried configuring it in
> > webapps/<appname>.xml but to no avail.
> >
> > Does anyone know how to make sure the connection pool closes all of its
> > connections when the context is removed?
> >
> > Thanks for your help,
> >
> > Tony.
> >
> >
> > ---------------------------------------------------------
> > Tony Locke                          tlocke@tlocke.org.uk.
> > ---------------------------------------------------------
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
>
>
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>


---------------------------------------------------------
Tony Locke                          tlocke@tlocke.org.uk.
---------------------------------------------------------


Mime
View raw message