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