C3P0错误APPARENT DEADLOCK!!!解决

来源:互联网 发布:淘宝客站内违规推广 编辑:程序博客网 时间:2024/06/05 03:35

在使用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