Recently I had to debug yet another occurrence of the infamous "java.net.SocketException: Broken pipe" issue with Hibernate and MySQL. This application uses Hibernate 3.3.2 GA with C3P0 0.9.1.2. Our pool configuration has been working for years, and although I had recently deployed a new feature that forks Java processes for large-scale asychronous reporting (another story...), I was pretty certain that was not the culprit. I have encountered this a few times over the past several years and had always attributed it to long periods of inactivity coupled with incorrect connection pool configuration, but this time I was hesitant to fool with the configuration since it had been working fine for years.
But since I now have multiple processes hitting the database I couldn't rule out a connection leak somewhere, so I started debugging. There are a couple of C3P0 properties that can be used for debugging connection leaks and other bad-client behavior: debugUnreturnedConnectionStackTraces and unreturnedConnectionTimeout.
So I figured I'd need to turn up the C3P0 logging to make sure I knew where to find the output that setting these properties may produce. When I didn't see any output from C3P0, I set the log level for Hibernate to make sure my Log4J config changes were picked up. As I scanned the output from Hibernate I noticed that Hibernate was not using C3P0 at all, but its own rudimentary connection pool instead. Puzzling, since my Hibernate configuration includes the C3P0 properties that according to the Hibernate documentation should cause Hibernate to use C3P0.
Apparently not... you now have to explicitly configure Hibernate to use C3P0 by setting hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider. That will get you back in business as far as Hibernate and C3P0 is concerned. I'm not sure exactly when this "feature' appeared... but if you upgrade Hibernate and suddenly see odd behavior like broken pipe errors from applications that previously worked fine, check your Hibernate configuration and make sure you are using the connection pool you think you are.