• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Tomcat Web app Timeout Issue

 
Bartender
Posts: 1971
17
  • 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
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.
 
No prison can hold Chairface Chippendale. And on a totally different topic ... my stuff:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic