• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Apache DBCP setup with Hibernate and MySQL

 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I've run into the apparently fairly well known problem with Hibernate and MySQL where connections time out and die. The purported fix is to implement connection pooling using DBCP or C3P0. I've done this using DBCP.

What I can't figure out is what is the difference between hibernate.dbcp.ps and hibernate.dbcp? They appear to be the same settings in the Hibernate config file, but the examples I've found give them difference values. And I can't seem to find any place that examples the difference. Apparently it's the prepared statement settings.

Even though I've implemented connection pooling with DBCP, my connections are still dieing. I get a MySQL exception stating that the close method has already been called. I'm using the settings from this site, which seem to be equivalent to the defaults.

http://www.informit.com/articles/article.aspx?p=353736&seqNum=4&rll=1

Anybody have suggestions on what to change? Right now I'm trying changing the regular maxWait to be the same as the prepared statement on. 1000*60*30

TIA.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bai Shen wrote:So I've run into the apparently fairly well known problem with Hibernate and MySQL where connections time out and die.



With pooling in place, if a connection in the pool has been idle for some configured time, then the connection is closed by the pool and moved out. This is expected. So in your case, can you explain which timeout you are referring to and what die means?
 
Bai Shen
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my hibernate config file.



The hibernate.dbcp.maxWait was originally -1, but I was still having problems so I changed it to match hibernate.dbcp.ps.maxWait

As far as I can tell, even though I have a connection pool, my connections are dieing. After a couple days, I can't connect to the database. Once I restart the web server, things start working again. I haven't made any changes to the database. It's a default 5.0 install. I don't have an error log handy atm. Next time it crashes I'll grab one and post it.

Any suggestions?
 
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