关于 spring ibatis多数据源问题
配置在这里就不多说了,基本在网上搜得一样,
项目启动后一旦访问数据库后,没几分钟就报异常,如下
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred while applying a parameter map.
--- Check the AUTHDEPARTMENT.SELECT_PAGE_LIST-InlineParameterMap.
--- Check the statement (query failed).
--- Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 445,587 milliseconds ago. The last packet sent successfully to the server was 18,300 milliseconds ago.
at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:201) ~[ibatis-sqlmap-2.3.4.726.jar:na]
at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForList(MappedStatement.java:139) ~[ibatis-sqlmap-2.3.4.726.jar:na]
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:567) ~[ibatis-sqlmap-2.3.4.726.jar:na]
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:541) ~[ibatis-sqlmap-2.3.4.726.jar:na]
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118) ~[ibatis-sqlmap-2.3.4.726.jar:na]
at org.springframework.orm.ibatis.SqlMapClientTemplate$3.doInSqlMapClient(SqlMapClientTemplate.java:298) ~[spring-orm-3.2.8.RELEASE.jar:3.2.8.RELEASE]
at org.springframework.orm.ibatis.SqlMapClientTemplate$3.doInSqlMapClient(SqlMapClientTemplate.java:296) ~[spring-orm-3.2.8.RELEASE.jar:3.2.8.RELEASE]
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:203) ~[spring-orm-3.2.8.RELEASE.jar:3.2.8.RELEASE]
... 52 common frames omitted
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 445,587 milliseconds ago. The last packet sent successfully to the server was 18,300 milliseconds ago.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.7.0_55]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) ~[na:1.7.0_55]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.7.0_55]
at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[na:1.7.0_55]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:409) ~[mysql-connector-java-5.1.30.jar:na]
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1127) ~[mysql-connector-java-5.1.30.jar:na]
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3715) ~[mysql-connector-java-5.1.30.jar:na]
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3604) ~[mysql-connector-java-5.1.30.jar:na]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4155) ~[mysql-connector-java-5.1.30.jar:na]
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2615) ~[mysql-connector-java-5.1.30.jar:na]
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2776) ~[mysql-connector-java-5.1.30.jar:na]
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2838) ~[mysql-connector-java-5.1.30.jar:na]
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082) ~[mysql-connector-java-5.1.30.jar:na]
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1307) ~[mysql-connector-java-5.1.30.jar:na]
at org.enhydra.jdbc.core.CorePreparedStatement.execute(CorePreparedStatement.java:82) ~[xapool-1.5.0.jar:"1.5.0"]
at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_55]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_55]
at com.ibatis.common.jdbc.logging.PreparedStatementLogProxy.invoke(PreparedStatementLogProxy.java:62) ~[ibatis-sqlmap-2.3.4.726.jar:na]
at com.sun.proxy.$Proxy16.execute(Unknown Source) ~[na:na]
at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:185) ~[ibatis-sqlmap-2.3.4.726.jar:na]
at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteQuery(MappedStatement.java:221) ~[ibatis-sqlmap-2.3.4.726.jar:na]
at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:189) ~[ibatis-sqlmap-2.3.4.726.jar:na]
... 59 common frames omitted
Caused by: java.net.SocketException: Operation timed out
at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.7.0_55]
at java.net.SocketInputStream.read(SocketInputStream.java:152) ~[na:1.7.0_55]
at java.net.SocketInputStream.read(SocketInputStream.java:122) ~[na:1.7.0_55]
at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:112) ~[mysql-connector-java-5.1.30.jar:na]
at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:159) ~[mysql-connector-java-5.1.30.jar:na]
at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:187) ~[mysql-connector-java-5.1.30.jar:na]
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:3158) ~[mysql-connector-java-5.1.30.jar:na]
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3615) ~[mysql-connector-java-5.1.30.jar:na]
... 75 common frames omitted
望大神指教如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是连接空闲了一段时间后自动超时了
jdbc url加上以下参数
autoReconnect=true
还会报错但不影响使用
同问 我的还有Connection has been abandoned PooledConnection这个异常