• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Tomcat Web app Timeout Issue

Posts: 1829
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
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.
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
    Bookmark Topic Watch Topic
  • New Topic