• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Timeout issue  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a web application running on tomcat server. The default wait_timeout for MySQL is 28800s i.e 8 hours. So, if there is no interaction with the server in 8 hrs, my application stops working and I have to reload it to make it work. Is there a solution for this?

P.S. I'm using hibernate's getCurrentSession instead of OpenSession.

Thanks in advance.
 
Saloon Keeper
Posts: 5476
143
Android Firefox Browser Mac OS X Safari Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The usual approach to handling connections would be to use a connection pool. Its connections would probably be cycled (or closed entirely) a lot sooner than 8 hours anyway. So I'm not sure how you figure that the wait_timeout value is relevant.
 
Rakesh Chandru
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's what I did. I changed the wait_timeout from its default value to 300 and I ran the test and noticed that the application was not responding after 5 min. Also, I'm using C3P0 for connection pooling. But it didn't solve the problem.
 
Bartender
Posts: 20725
124
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There should be a connection pool option that allows you to tell the pool to discard expired connections and create new ones. It's usually paired with a "liveness test", which is a simple SQL query that's invoked on the Connection before assigning it to the webapp. The details vary somewhat depending on what DBMS you use.

When that mechanism is set up, any time the app requests a Connection, the pool pulls the next available one, does the "liveness test", and if the test succeeds, passes the Connection on to the requester. If the Connection is dead, it's discarded from the pool (destroyed) and a new Connection is retrieved, repeat as needed. If the pool runs empty (or maybe below a minimum threshold), then the pool will create new Connections and add them to the pool.
 
He repaced his skull with glass. So you can see his brain. Kinda like this tiny ad:
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!