• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Apache DBCP setup with Hibernate and MySQL

 
Bai Shen
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • 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.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic