Database Connection to MySQL times out even after setting c3p0.testConnectionOnCheckout=true

后端 未结 2 425
孤城傲影
孤城傲影 2021-01-19 02:08

I have an app that uses hibernate (v3.6.4) , with connection pooling provided by C3P0 (v0.9.1.2) .

The problem is I get a JDBC communications link failure if I make

相关标签:
2条回答
  • 2021-01-19 02:57

    We started having the same "Communications Link" issue when we upgraded hibernate to 4.3.x using JPA and C3P0 for connection pooling.

    It seems like this would be a connection pool issue since connections were being kept longer than the database wait_timeout (which was the default 8 hours) despite my C3P0 settings. However, I fixed the issue by changing the hibernate configuration in our persistence.xml with:

    <property name="hibernate.connection.release_mode" value="after_transaction" />
    

    It seems the default behavior in hibernate changed to not release the connection after transactions, so you have to explicitly set this mode if you're using pooling.

    0 讨论(0)
  • 2021-01-19 03:01

    Add the below property in your hibernate config file. I hope it will work.

    <property name="connection.provider_class">
      org.hibernate.connection.C3P0ConnectionProvider
    </property>
    
    0 讨论(0)
提交回复
热议问题