MySql有一个系统变量,如图:
以上数值,单位为秒。
mysql的连接允许的闲置时间。当超过闲置时间以后,database端就会将此连接单方面废弃。这时如果使用jdbc继续使用之前的连接,则会收到以下异常:
### Cause: java.sql.SQLException: Could not retrieve transation read-only status server
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:111)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
at com.sun.proxy.$Proxy8.getMonthlyChart(Unknown Source)
at com.lux.rcc.kpi.bo.ChartABo.getMonthlyChart(ChartABo.java:46)
at com.lux.rcc.kpi.servlets.ChatAServlet.doGet(ChatAServlet.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFil