Hibernate documentation claims that turning on the c3p0 connection pooling provider requires only setting the property hibernate.c3p0.max_size in hibernate configuration file.
(Note: I'm using the hibernate.properties configuration, not the hibernate.cfg.xml, however this shouldn't make much of a difference)
After I set required hibernate.c3p0.* properties in my hibernate.properties file, and by reviewing the hibernate log in my IDE's console, I found this conspicious line:
INFO DriverManagerConnectionProvider:64 - Using Hibernate built-in connection pool (not for production use!)
which means that hibernate is still not using c3p0.
After searching online, I found a hint that c3p0 can be turned on by setting the property hibernate.connection.provider_class to the value org.hibernate.connection.C3P0ConnectionProvider in my hibernate configuration file (or actually by uncommenting it in the hibernate distribution's default hibernate.properties file).
Then the conspicios log line happily switches to:
INFO ConnectionProviderFactory:95 - Initializing connection provider: org.hibernate.connection.C3P0ConnectionProvider
I had to add org.hibernate:hibernate-c3p0 (version 3.3.1.GA) to my list of maven dependencies to avoid having the following exception thrown:
org.hibernate.HibernateException: Could not instantiate connection provider: org.hibernate.connection.C3P0ConnectionProvider
Hint: hibernate-c3p0 is a C3P0-based implementation of the Hibernate ConnectionProvder contract (as defined by http://mvnrepository.com/artifact/org.hibernate/hibernate-c3p0)
hibernate-c3p0 automatically calls c3p0:c3p0 (version 0.9.1) as a transitive dependency.
Versions of Interest:
Maven 2.0.9
Technologies of Interest (Tags):
Java