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.
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?
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.
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