hibernate+mysql 8小时问题

在生产环境中使用了 自带的连接池 结果 遇到 mysql8小时问题

然后 采用了 c3p0 连接池

hibernate 版本 4.3.6

c3p0版本 0.9.5-pre10

ps:hibernate-c3p0 4.3.6 默认引用的 0.9.2.1的c3p0有点问题。

如果不想使用 0.9.5以上的 c3p0池 需要在 hibernate config 里面添加

<property name="hibernate.c3p0.preferredTestQuery">select 1</property>


!!!重要:http://www.mchange.com/projects/c3p0/index.html#configuring_connection_testing

文中 说 如果 你确定你用的是jdbc4+ 而且 c3p0 0.9.5以上 就可以不同配 这个
preferredTestQuery属性,如果不确定就必须配上这个属性,不然配置idle_test_perio不起作用

配置如下:

 <!-- c3p0 pool config-->
        <property name="hibernate.connection.provider_class">org.hibernate.c3p0.internal.C3P0ConnectionProvider</property>
        <property name="hibernate.c3p0.max_size">100</property>
        <property name="hibernate.c3p0.min_size">5</property>
        <property name="hibernate.c3p0.timeout">1200</property>
        <property name="hibernate.c3p0.max_statements">0</property>
        <property name="hibernate.c3p0.idle_test_period">60</property>
        <property name="hibernate.c3p0.acquire_increment">5</property>
<property name="hibernate.c3p0.preferredTestQuery">select 1</property>
 

 

posted @ 2014-10-11 20:51  沐松  阅读(699)  评论(0编辑  收藏  举报