Reproduced from: http://japi.iteye.com/blog/254786
Thank the original author
There have been a lot of errors in the use of c3p0. The longest sight is a deadlock, which occupies a relatively large resource.
For deadlock problems http://japi.iteye.com/blog/243702. Found the solution (not fully guaranteed, but in the load test, there are no problems)
The key to the problem is the setting of the parameter
Reference
<!--JDBC Standard parameters to control the number of preparedstatements loaded in the data source. But because of the statements of the cache
belong to a single connection rather than the entire connection pool. So setting this parameter takes into account many factors.
If both maxstatements and maxstatementsperconnection are 0, the cache is closed. Default:0-->
<property name= "Maxstatements" >100</property>
<!--maxstatementsperconnection defines the maximum number of cached statements that a single connection has within a connection pool. default:0-->
<property name= "Maxstatementsperconnection" ></property>
The solution is:
Reference in Hibernate.cfg.xml:
<property name= "Hibernate.c3p0.max_statements" >0</property>
In C3p0.properties:
C3p0.maxstatements=0
c3p0.maxstatementsperconnection=100