连接mysql的时候经常出现以下报错:
### Error querying database. Cause: java.sql.SQLNonTransientConnectionException: Communications link failure during rollback(). Transaction resolution unknown.
### The error may exist in mapper/baselectureinfoMapper.xml
### The error may involve com.zy.entity.mapper.BaselectureinfoMapper.selectBaselectureinfoById
### The error occurred while executing a query
### Cause: java.sql.SQLNonTransientConnectionException: Communications link failure during rollback(). Transaction resolution unknown.
org.apache.ibatis.reflection.wrapper.BeanWrapper.setBeanProperty(BeanWrapper.java:185)
org.apache.ibatis.reflection.wrapper.BeanWrapper.set(BeanWrapper.java:59)
org.apache.ibatis.reflection.MetaObject.setValue(MetaObject.java:140)
org.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyAutomaticMappings(DefaultResultSetHandler.java:527)
org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:402)
org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:354)
org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:328)
org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:301)
org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:194)
org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:65)
org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63)
org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324)
org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77)
org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:84)
org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58)
com.sun.proxy.$Proxy6.selectBasecourseinfoById(Unknown Source)
网上各种找问题解决方式,各种尝试都无法解决,最中看代码发现,是有一个地方没有获取session之后没有关闭,导致连接用完导致的。只要使用
session.close();
就OK了。
以作记录。