User Manual
Connection pooling using C3P0
Table 20 Property settings for C3P0 connection pooling
Example valuePropertyProperty meaning
15hibernate.c3p0.max_sizeMaximum number of database connections to open
3hibernate.c3p0.min_sizeInitial number of database connections
5000hibernate.c3p0.timeoutMaximum idle time for a connection (in seconds)
0hibernate.c3p0.max_statementsMaximum size of c3p0 statement cache (0 to turn off)
3hibernate.c3p0.acquire_incrementNumber of connections in a clump acquired when pool is
exhausted
300hibernate.c3p0.idle_test periodIdle time before a c3p0 pooled connection is validated (in
seconds)
Validate the connection on checkout. HP recommends setting the hibernate.c3p0.idle_test_period property instead.
Defaults to false.
The following is a sample of C3P0 configuration of hibernate.cfg.xml:
<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.min_size">3</property>
<property name="hibernate.c3p0.max_size">15</property>
<property name="hibernate.c3p0.timeout">5000</property>
<property name="hibernate.c3p0.max_statements">0</property>
<property name="hibernate.c3p0.acquire_increment">3</property>
<property name="hibernate.c3p0.idle_test period">300</property>
All other properties must be defined in a c3p0.properties file. Put this file in the CLASSPATH
(WEB-INF/classes for example). However, if some of the properties listed above are specified in
c3p0.properties, they will be overridden by the configuration you have set in your Hibernate
configuration file.
The following is a sample configuration of c3p0.properties file:
c3p0.initialPoolSize=1
c3p0.checkoutTimeout=400
For the complete list of C3P0 properties, see http://www.mchange.com/projects/c3p0/
index.html#configuration_properties.
Connection pooling using Proxool
Proxool is another open source JDBC connection pool distributed with Hibernate.
Table 21 Property settings for Proxool connection pooling
Example valuePropertyProperty Meaning
/path/to/file.xmlhibernate.proxool.xmlConfigure Proxool provider using an XML file
/path/to/proxoolhibernate.proxool.propertiesConfigure the Proxool provider using a properties file
true | falsehibernate.proxool.existing_poolConfigure the Proxool provider from an existing pool
As set by Proxool
configuration
hibernate.proxool.pool_aliasProxool pool alias to use (required for
hibernate.proxool.existing_pool
hibernate.proxool.properties
hibernate.proxool.xml
)
The following is a sample of Proxool configuration:
<property
name="hibernate.connection.provider_class">org.hibernate.connection.ProxoolConnectionProvider</property>
<property name="hibernate.proxool.pool_alias">property</property>
<property name="hibernate.proxool.properties">property</property>
A sample proxool.properties file looks like this:
Configuring Hibernate Applications on NonStop Systems 113