Spring boot connection MySQL long time not connected after error ' com.mysql.cj.core.exceptions.ConnectionIsClosedException:No operations allowed after Connection closed. ' Solution

Source: Internet
Author: User

Error:com.mysql.cj.core.exceptions.ConnectionIsClosedException: No operations allowed after connection closed.

Adding &autoReconnect=true does not help, this option appears to be valid only for versions prior to MySQL 5.

Reason

MySQL server default "Wait_timeout" is 8 hours, which means that a connection idle for more than 8 hours, MySQL will automatically disconnect the connection. This is the problem, in the C3P0 pools connections if idle for more than 8 hours, MySQL will disconnect it, and c3p0 do not know that the connection has failed, if there is a client request connection, C3P0 the failure of the connection to the client, will cause the above exception.

Solutions

Http://www.cnblogs.com/hemingwang0902/archive/2012/03/15/2397620.html

Temporary Solutions

Because the above method needs to modify the database, but I do not want to change the database. So:
Modify the driver to connect to MySQL (Modify application.properties):
From

spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver

Switch

spring.datasource.driverClassName=com.mysql.jdbc.Driver

Spring boot connection MySQL long time not connected after error ' com.mysql.cj.core.exceptions.ConnectionIsClosedException:No operations allowed after Connection closed. ' Solution

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.