What are the required C3P0 settings for hibernate in order to avoid Deadlocks

后端 未结 6 1415
梦毁少年i
梦毁少年i 2020-12-07 11:36

I use Hibernate together with MySQL 5.1.30.

I have the next libraries:

  • c3p0-0.0.1.2.jar
  • mysql-connector-java-5.0.3
6条回答
  •  旧巷少年郎
    2020-12-07 11:44

    Actually this is probably too late, but the problem is quite simple: hibernate.c3p0.idle_test_periods must not be higher than hibernate.c3p0.timeout or connections closed by the database will not be properly detected.

    Moreover, the deadlock detection warnings look like some part of your code is not properly returning the connections to the pool (i.e. session.close())

    The MysqlIO exceptions occur when your application idles and MySQL closes the connection on the server. Now if C3P0 does not properly check whether a connection is still actually connected you get the EOFExceptions.

    I hope this might be helpful.

提交回复
热议问题