tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: How to close all connections in a Tomcat container db connection pool?
Date Wed, 11 May 2011 13:55:43 GMT
Hash: SHA1


On 5/10/2011 7:24 PM, Dale Ogilvie wrote:
> The cause of the error was the db admin patching a db package underlying
> one used by our web-app. Post patch all the packages appeared valid to
> the admin, but not to our app using db connections established prior to
> the db patching.

Looks like the Oracle connection caches some of that metadata. Maybe
your dba shouldn't mess with that kind of stuff while the application is
running :)

> Is there any way to tell the running Tomcat to clean out the connection
> pool, so that it throws away all the established connections, and
> establishes new ones for the applications. I don't really want to have
> to stop all the applications on our server to deal with this sort of
> issue.

You'll have to basically reach-into the JNDI context, pull-out the
DataSource object, cross your fingers and cast it to some "known" object
type (like org.apache.tomcat.dbcp.dbcp.BasicDataSource) and then call
methods on that Tomcat-specific class.

You could call the "close" method on that class, but I suspect you'll
end up with an empty, useless pool at that point. It's possible that the
pool will re-initialize itself when you call getConnection but you'll
have to check that out for yourself.

You could also look into using JMX, but you'll have to poke around
looking for the key for your DataSource and then I don't have any idea
what actions are available... YMMV.

Maybe there's a method on the Oracle-specific connection object(s) that
you can use to flush all the metadata. You might want to look into that,

Finally, if you use a webapp-specific DataSource (that is, not a
"global" one) and you properly close the DataSource when the webapp
shuts down, a new one should be created for your when the new instance
of the webapp launches.

Hope that helps,
- -chris
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message