数据加载中……

2009年12月27日

c3p0

C3P0错误APPARENT DEADLOCK!!!解决

1楼   2008-10-18

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

对于死锁问题http://japi.javaeye.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

来源于: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=6fcfab70cff3588bf010914df8dbbb90

http://www.mchange.com/projects/c3p0/index.html#c3p0_properties
2楼  LifeFree 2009-05-04

唉,早看到别人说要maxStatements设置为0,就是没怎么用c3p0,不知道具体情况。
前段时间在一个事务里多加了条sql语句,原来并发没问题的,后来发现性能很低。查了很久才发现是死锁了,又搞了很久才想到是c3p0的问题。

posted @ 2009-12-27 18:23 jeter123 阅读(601) | 评论 (0)编辑 收藏
仅列出标题