I have a web app where a servlet is included in the web.xml file so it's instantiated. Now, the issue is that after, say, 12 hours, if you try to start the application, the Connection object created in the init() of the servlet to access the database has been closed. There is no timeout clause in web.xml. Is this a feature of Web apps under Tomcat or is there something else going on? Any advice would be appreciated! -- Mike
Mike, I think you need you rethink your design a bit. You should not have a single Connection open and servicing every request of a Servlet... at the very worst, you should have each request open its own Connection (if for some reason you need to). I would recommend using a pooled connection with the connection refresh set to something like an hour or two -- depends on your DB and your app. You can get pooling from a DataSource or if your DB does not support a pooled DataSource (or DataSource at all), you may want to look at DBCP from Jakarta: http://jakarta.apache.org/commons/dbcp/ It will create a DataSource from a non-DataSource driver and then pool it for you. Connection pooling will solve your problem. Hope this helps.
- Chris Stehno, SCPJ
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop