• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Tomcat Web app Timeout Issue

 
Bartender
Posts: 1829
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.
 
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
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic