MySQL 8-hour connection timeout time, causing the system to crash overnight, error could not roll back Hibernate transaction

Source: Internet
Author: User
Tags connection pooling tomcat server apache tomcat

March 2014 began to the unit development of "standardized management network platform", the end of October successfully launched, but there is a bug:

deployment Environment: Apache Tomcat 6.0.41 + mysql5.5 + jbpm

How to Reproduce the bug: after deploying the environment, in the absence of user access to the system, after a night, the next day to log in will report the following error: Could not roll back Hibernate transaction; Nested exception is Org.hibernate.TransactionException:JDBC rollback failed.

* Solution to find primary (surface) article: at the beginning, Baidu, Google "Could not roll back Hibernate transaction; Nested exception is Org.hibernate.TransactionException:JDBC rollback failed. ". Review after the solution found on the Internet, I feel that can not solve my problem.

* Solution Lookup Advanced (in-depth): Find the log of Tomcat, located at:%tomcat_home%\logs\%service_name%-stdout.2015-02-25.log. (Note: The Run-time error log is not found in Stderr.xxx.log; Tomcat automatically starts after restarting the server, registering Tomcat as the service under window)

To view the call stack for the error location:

STACKTRACE:

Com.mysql.jdbc.CommunicationsException:Communications link failure due to underlying exception:

* * BEGIN NESTED EXCEPTION * *

Java.net.SocketException

Message:software caused connection Abort:socket write error

STACKTRACE:

Java.net.SocketException:Software caused connection Abort:socket write error

At Java.net.SocketOutputStream.socketWrite0 (Native Method)

... ... ...

Root cause:

The tomcat server is disconnected from the MySQL database for a period of time without access, and an error occurs:
    java.net.socketexception: software  caused connection abort: socket write error
Because the connection time-out for MySQL is 8 hours. If you are idle for more than 8 hours, MySQL will automatically disconnect.

Solution:
Use connection pooling to solve this problem, use C3P0 here:
Modify the Hibernate.cfg.xml file
<property name= "Hibernate.connection.provider_class" >org.hibernate.connection.c3p0connectionprovider</ Property>
< property name= "Hibernate.c3p0.min_size" >8</property>
< property name= "Hibernate.c3p0.max_size" >200</property>
< property name= "Hibernate.c3p0.timeout" >600</property>
< property name= "Hibernate.c3p0.max_statements" >0</property>
< property name= "Hibernate.c3p0.idle_test_period" >60</property>
< property name= "Hibernate.c3p0.acquire_increment" >2</property>
< property name= "Hibernate.c3p0.validate" >true</property>

MySQL 8-hour connection timeout time, causing the system to crash overnight, error could not roll back Hibernate transaction

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.