Hello All!
Our team here has written a simple Connection Pool
class that is a singleton.
I've noticed that whenever Tomcat reloads my webapps
context (when I add a new class or something like
that), that it the next call to the Connection Pool
get instance method doesn't see the previous
singleton, and hence, it allocates a bunch of new
connections.
This would be fine, except that the old connections
are never closed (it seems that the Garbage Collector
doesn't eat them up) so I think that the old instance
of the singleton is still floating around in the JVM
somewhere.
This causes all the free sessions on the Database to
be eaten up, forcing a restart of tomcat. Once tomcat
is restarted, all the connections are closed out
(since the JVM terminated, I guess) and things are
fine again.
What do I need to do so that the old connections are
removed? This is on Tomcat 3.3.1a. Here is the
relevent code of the Singleton getInstance method:
public static synchronized ConnectionPool
getInstance(ConnectionPoolConstants c) throws
SQLException {
constants = c;
if (instance == null) {
// Determine which database url to connect
db_url = constants.getTestDBURL();
String line = "";
try {
Vector return_vec =
DelphiRuntime.execCommandWithOut("hostname");
Enumeration return_enum =
return_vec.elements();
while (return_enum.hasMoreElements())
{
line = (String)
return_enum.nextElement();
}
} catch (InterruptedException ire) {
} catch (IOException ioe) {
}
if
(line.equals(constants.getProductionServerHostname()))
{
db_url =
constants.getProductionDBURL();
}
instance = new ConnectionPool();
}
return instance;
}
Thanks for any insights!
Cheers!
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]