C3P0错误APPARENT DEADLOCK!!!解决

来源:互联网 发布:java 大并发处理 编辑:程序博客网 时间:2024/06/06 07:13

转载自:http://japi.iteye.com/blog/254786 


感谢原作者

在使用C3P0的过程中出现了好多错误.最长见就是死锁,占用资源比较大. 

对于死锁问题http://japi.iteye.com/blog/243702.找到了解决方案(不能完全保证,但在负载测试中,还没有出现问题) 

问题关键是参数的设置 
引用

<!--JDBC的标准参数,用以控制数据源内加载的PreparedStatements数量。但由于预缓存的statements 
属于单个connection而不是整个连接池。所以设置这个参数需要考虑到多方面的因素。 
如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default: 0--> 
<property name="maxStatements">100</property> 

<!--maxStatementsPerConnection定义了连接池内单个连接所拥有的最大缓存statements数。Default: 0 --> 
<property name="maxStatementsPerConnection"></property> 


解决的方法是: 
引用
In hibernate.cfg.xml: 
<property name="hibernate.c3p0.max_statements">0</property>  


In c3p0.properties: 
c3p0.maxStatements=0 
c3p0.maxStatementsPerConnection=100 
 

阅读全文
0 0
原创粉丝点击