Many errors occurred when using c3p0. The longest possible cause is deadlock, which occupies a large amount of resources.
Http://japi.javaeye.com/blog/243702 for deadlock issues.
Found the solution (not completely guaranteed, but there is no problem in the load test)
The key issue is parameter settings.
Reference
<! -- JDBC standard parameter, used to control the number of preparedstatements loaded in the data source. However, due to the pre-Cache statements
Belongs to a single connection pool rather than the entire connection pool. Therefore, you need to consider many factors when setting this parameter.
If both maxstatements and maxstatementsperconnection are 0, the cache is disabled. Default: 0 -->
<Property name = "maxstatements"> 100 </property>
<! -- Maxstatementsperconnection defines the maximum number of statements cached for a single connection in the 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
From: http://forum.hibernate.org/viewtopic.php? P = 2386237
Http://forum.hibernate.org/viewtopic.php? T = 947246 & START = 0 & postdays = 0 & postorder = ASC & Highlight = apparent + deadlock + c3p0 & SID = 6fcfab70cff3588bf01_14df8dbbb90
Http://www.mchange.com/projects/c3p0/index.html#c3p0_properties