• 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

wait _ timeout breaks connection (mysql related)

 
Ranch Hand
Posts: 147
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Need a little help here if possible....

1) I am using hibernate with mysql and tomcat 6.
2) I wish to alter the default 8 hour wait time that mysql comes with.
3) In doing so I have modifies my /etc/my.inf to include the lines:

interactive_timeout=604800
interactive_timeout=604800

I then do a restart of mysql server and a show variable query on timout to confirm that the values on no longer defaults.

My system then breaks as tomcat is not able to use hibernate pool for authentication and aditionally the following happens:

I create a new 'test' user and the application works. Additionally trying to recreate the user brings about the necassary exceptions I have defined, indicating that the new test user is sitting in the cache but is never flushed.

Removing the configuration I did makes it work again but I then have to deal with the 8 hour timeout again.

Many thanks for any help.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


My system then breaks as tomcat is not able to use hibernate pool for authentication and aditionally the following happens:


It is not clear why this breaks

The 'standard' solution is to the use the autoReconnect=true on the JDBC URL, and additionaly to specify for the DB pool to testOnBorrow true and set a validation query.
The problem here has several levels. Firstly there is the issue that MySQL times out connections that are idle for 8 hours (by default). Changing this value can help a little but is more of a hack than a solution.
The next problem is that the pool is unaware of bad Connections unless you tell it that a Connection has gone bad. The autoReconnnect setting setting tells the MySQL Driver to recreate any connections that fail, and by using the testOnBorrow, you allow the connection to fail and be recreated before the connection gets passed to your application.

While autoReconnect=true is no longer the preferred solution, I haven't had much luck with the 'reconnect for polled connection' setting (I forget what it is called).
reply
    Bookmark Topic Watch Topic
  • New Topic