mysql 连接问题 有时会报事务连接失败 查询sql不是不需要事务,我也没配事务啊

薛定谔_我毛呢 发布于 2016/04/14 13:37
阅读 2K+
收藏 0

华为云11月刊推送:DIY微信问答机器人,高性能计算代码的20个技巧!>>>

就一个查询sql  然后导出excel    没有涉及到事务 我也没有配事务, 为什么部署到远端linux系统后 每天前几次连接都会出现这种问题. 这是为什么啊? 多请求几次这个借口 就会变得正常,  然后很长一段时间都是正常的,  然后过一段时间就会重新报这个错,  又会重新遇到以下的报错.       希望大神能够帮我分析一下.  我这个是一个单独的接口,  由于是一个提供简单接口的小项目 ,  没用很重的框架 ,直接用了servlet+mybatis   没有配事务   也不需要事务 , 不知道为什么会报事务回滚的连接出错,,,,,  希望各路大神可以指点一下!!!!

这到底是生产环境的mysql的配置问题  还是我项目里面mybatis的配置问题?   或者是其他问题



exception

org.apache.ibatis.exceptions.PersistenceException:

### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Communications link failure during rollback(). Transaction resolution unknown.

### The error may exist in OrderInfoMapper.xml

### The error may involve com.axinpay.orderToExcel.mapper.OrderInfoMapper.findByDate

### The error occurred while executing a query

### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Communications link failure during rollback(). Transaction resolution unknown.

    org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)

org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:107)

org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98)

        org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:114)

        org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:58)

        org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43)

        $Proxy6.findByDate(Unknown Source)

com.axinpay.orderToExcel.service.impl.OrderInfoServiceImpl.findByDate(OrderInfoServiceImpl.java:20)

      com.axinpay.orderToExcel.servlet.OrderInfoServlet.service(OrderInfoServlet.java:61)

        javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

root cause

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Communications link failure during rollback(). Transaction resolution unknown.

        sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

        java.lang.reflect.Constructor.newInstance(Constructor.java:513)

        com.mysql.jdbc.Util.handleNewInstance(Util.java:411)

        com.mysql.jdbc.Util.getInstance(Util.java:386)

        com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)

        com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)

        com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)

        com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)

        com.mysql.jdbc.ConnectionImpl.rollback(ConnectionImpl.java:5068)

org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:391)

org.apache.ibatis.datasource.pooled.PooledDataSource.getConnection(PooledDataSource.java:82)

org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:131)

org.apache.ibatis.transaction.jdbc.JdbcTransaction.getConnection(JdbcTransaction.java:58)

        org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:271)

       org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:69)

        org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:56)

        org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:259)

        org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:132)

        org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105)

        org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81)

org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104)

org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98)

        org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:114)

        org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:58)

        org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43)

        $Proxy6.findByDate(Unknown Source)

com.axinpay.orderToExcel.service.impl.OrderInfoServiceImpl.findByDate(OrderInfoServiceImpl.java:20)

      com.axinpay.orderToExcel.servlet.OrderInfoServlet.service(OrderInfoServlet.java:61)

        javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.63 logs.

加载中
0
ulfl
ulfl
我也是遇到这个问题,请问你的问题解决了吗,我用的是Ibatis,看了下网上说的好像是说连接断开了,导致的,也不清楚要怎么做
0
返回顶部
顶部