c3p0 for open source's JDBC connection pool, with the release hibernate. This article describes how to use the hibernate configuration in c3p0.
c3p0 connection pool configuration is very simple, only needs to increase in hibernate.cfg.xml:
<property name="hibernate.c3p0.max_size"> 20 </ property>
<! - The smallest number of connections ->
<property name="hibernate.c3p0.min_size"> 5 </ property>
<! - Get connection timeout, if more than this time will be thrown, unit ms ->
<property name="hibernate.c3p0.timeout"> 120 </ property>
<! - The largest number of PreparedStatement ->
<property name="hibernate.c3p0.max_statements"> 100 </ property>
<! - Every 120 seconds to connect the pond to check the idle connection, units are seconds ->
<property name="hibernate.c3p0.idle_test_period"> 120 </ property>
<! - When the connection inside the connection pool run out of time, C3P0 click access to the new connections ->
<property name="hibernate.c3p0.acquire_increment"> 2 </ property>
<! - Every time, verify the connection is available ->
<property name="hibernate.c3p0.validate"> true </ property>
In addition, where necessary in CLASS_PATH add c3p0-xxxjar file (xxx is version number), c3p0-xxxjar document released in conjunction with hibernate, you may, in its lib directory to find the file.
After configuration, hibernate will automatically use the c3p0 connection pool: C3P0ConnectionProvider







