<span style="color: rgb(50, 50, 50); text-align: center; background-color: rgba(255, 255, 255, 0.01);">wait_timeout</span>
设置非交互连接(就是指那些连接池方式、非客户端方式连接的)的超时时间,默认是28800,就是8小时,<br>超过这个时间,mysql服务器会主动切断那些已经连接的,将状态置为是sleep<br>
查看mysql服务端设置:
<br>mysql> show variables like '%timeout%';
常见异常
The last packet successfully received from the server was 47,795,922 milliseconds ago.<br> The last packet sent successfully to the server was 47,795,92 原因分析:MySQL连接时,服务器默认的“wait_timeout”是8小时,<br>也就是说一个connection空闲超过8个小时,Mysql将自动断开该connection。connections如果空闲超过8小时,<br>Mysql将其断开,而DB连接池并不知道该connection已经失效,如果这时有Client请求connection,<br>连接池将该失效的Connection提供给Client,将会造成异常。<br>