Does anybody know how to disable connection pooling in hibernate ? Im getting broken pipe exceptions after about 8 hours of operation, which corresponds to the time that, i believe, a connection pool takes to go stale if you are using mysql.... Anyways... Let me know ! thanks. JAy
I'm not sure which forum would have been the best place to ask, but it almost certainly wasn't this one.
Your cure is worse than the disease. There's a reason for connection pooling. However, Hibernate isn't normally going to be responsible for providing the pooling mechanism. That's normally handled by the datasource infrastructure. In Tomcat, it would be provided as part of the application context. For a stand-alone application, you could include your own.
You need to read the docs on whatever pooling datasource you're using (for Tomcat, the default one is apache dbcp). You'll probably find an option designed to check connections managed by the pool and ensure that they're still usable before passing them on to the application (if not, the connection is discarded and a new one is built, if needed).
Note that this won't protect you if you pull a connection from the pool and hold onto it inside the application for 8 hours or so. But that's bad practice anyway. The whole point of connection pooling is that you get a connection quickly, use it for a short time, then return it back to the pool so someone else can do likewise.
Actually, the default timeout for Mysql is more like 30 minutes, I believe. Although I've known people to up it to hack around problems.
When using pooled connections, it's also critical to ensure that they don't "leak". If you're not faithfully returning used connections to the pool (via the connection close() method), eventually the pool will run dry. But bypassing pooling is worse yet, since you'll still eventually run out of connections, since each connection requires a network socket resource, and there's a finite number of them for the entire OS.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Aug 30, 2005
just added the c3po configuration tags to hibernate.cfg.xml , this seemed to fix it . Thanks. !
I guess hibernate connection pooling really automagically solves this problem for you.