Connector/J connection property 'autoReconnect=true' to avoid this problem
来源:互联网 发布:联通网络如何报修 编辑:程序博客网 时间:2024/06/08 17:12
连接池出现问题,为MYSQL自动断开连接引起的,如果一个系统在8-15小时后未使用连接,那么MYSQL会自动断开连接。而此时数据库连接池是不知道的。此时在使用时就会报此错误。
当前系统平台为HIBERNATE+MYSQL+PROXOOL进行数据库连接。异常日志为:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 55,623,408 milliseconds ago. The last packet sent successfully to the server was 55,623,408 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:989)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3746)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2509)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2494)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1966)
at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeQuery(FilterChainImpl.java:2830)
at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_executeQuery(FilterEventAdapter.java:465)
at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeQuery(FilterChainImpl.java:2827)
at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.executeQuery(PreparedStatementProxyImpl.java:182)
at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeQuery(DruidPooledPreparedStatement.java:228)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1808)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.StatelessSessionImpl.list(StatelessSessionImpl.java:490)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:835)
at com.css.db.query.QueryCache.uniqueResult(QueryCache.java:198)
八月 22, 2017 9:11:27 上午 org.hibernate.jdbc.AbstractBatcher closeQueryStatement
警告: exception clearing maxRows/queryTimeout
java.sql.SQLException: No operations allowed after statement closed.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:897)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:886)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
at com.mysql.jdbc.StatementImpl.checkClosed(StatementImpl.java:442)
at com.mysql.jdbc.StatementImpl.getMaxRows(StatementImpl.java:1870)
at com.alibaba.druid.filter.FilterChainImpl.statement_getMaxRows(FilterChainImpl.java:2522)
at com.alibaba.druid.filter.FilterAdapter.statement_getMaxRows(FilterAdapter.java:2556)
at com.alibaba.druid.filter.FilterChainImpl.statement_getMaxRows(FilterChainImpl.java:2520)
at com.alibaba.druid.proxy.jdbc.StatementProxyImpl.getMaxRows(StatementProxyImpl.java:331)
at com.alibaba.druid.pool.DruidPooledStatement.getMaxRows(DruidPooledStatement.java:395)
at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:298)
at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:234)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1822)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
将数据源改成容器控制,使用druid数据源连接数据库
修改tomcat/conf/context.xml增加:
<Resource
name="jdbc/ebs"
factory="com.alibaba.druid.pool.DruidDataSourceFactory"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://10.192.2.250:3306/test?useUnicode=true&characterEncoding=utf-8&autoReconnect=true"
username="test"
password="132456"
timeBetweenEvictionRunsMillis="60000"
minEvictableIdleTimeMillis="300000"
maxActive="50"
initialSize="1"
minIdle="1"
testWhileIdle="true"
maxWait="10000"
filters="stat"/>
</Context>
在tomcat/lib下增加 jar包
druid-1.1.2.jar
log4j-1.2.17.jar
具体配置参数详见阿里巴巴开源的配置。
- using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
- using the Connector/J connection property 'autoReconnect=true' to avoid this problem
- using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
- Connector/J connection property 'autoReconnect=true' to avoid this problem
- 日志:using the Connector/J connection property 'autoReconnect=true' to avoid this problem
- mysql超时设置的问题 using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
- 连接数据库超时设置autoReconnect=true
- 连接数据库超时设置autoReconnect=true
- 连接数据库超时设置autoReconnect=true
- 连接数据库超时设置autoReconnect=true
- 异常:calling prepareStatement is no longer allowed! Increase reapTimeout to avoid this problem
- Hibernate连接数据库超时设置autoReconnect=true(Mysql)
- Hibernate连接数据库超时设置autoReconnect=true
- Hibernate连接数据库超时设置autoReconnect=true
- Hibernate连接数据库超时设置autoReconnect=true
- Hibernate连接数据库超时设置autoReconnect=true
- Mysql 连接数据库超时设置autoReconnect=true
- Mysql 设置超时重连 autoReconnect=true
- 伟大的领袖如何激励行动
- java 中@Override的作用
- C++编程->pcap文件读取源码
- linux远程连接linux
- JAVA按模版导出PDF文件,含条码,二维码,表格
- Connector/J connection property 'autoReconnect=true' to avoid this problem
- 你的Dom4j-----DOM4j解析用法详解
- WordPress数据备份
- 利用宏定义生成getset私有变量函数
- 明明的烦恼(Prufer数列)
- java常量池
- Python | Pip 安装模块速度MB级提升
- 如何递归遍历文件夹里所有文件
- 将BUFG上的时钟信号通过FPGA的普通IO输出