The last packet successfully received from the server was 78,682,686 milliseconds ago. The last packet sent successfully to the server was 78,682,686 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
这个问题通俗的讲是这样的mysql配置里面有个wait_timeout( show global variables like 'wait_timeout';) 这个值表示的是connection允许的最大空闲时间,一个connection空闲时间超过了这个值就会被销毁。如果你使用的连接池允许的最大空闲时间大于mysql的最大空闲时间就会出现mysql把这个连接销毁了而连接池这边还保留着这个连接,当有请求的时候连接池用这个连接的时候就会报这个错误。
所以解决这个问题的办法就是保证连接池这边的connection比mysql那边先过期。
c3p0配置:
<property name="maxIdleTime" value="28700" /> <!-- 这个值要小于mysql的wait_timeout默认值28800 -->
其他的自己琢磨。