tomcat dbcp 基于jndi配置时出现java.sql.SQLException: Already closed
2014-08-20 10:07
645 查看
最近观察生产环境发现一个现象,一段时间不操作,再重新操作时,数据库连接第一次会出现:java.sql.SQLException: Already closed.,如下:
error log: ( org.springframework.dao.RecoverableDataAccessException: PreparedStatementCallback; SQL [select user_id,login_name from t_sys_user where login_name=? and password=?]; The last packet successfully received from the server was1290665 seconds ago.The
last packet sent successfully to the server was 1290665 seconds ago, which 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.; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server
was1290665 seconds ago.The last packet sent successfully to the server was 1290665 seconds ago, which 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. )
数据源是用tomcat dbcp 基于jndi配置管理的,查了下,如下:
原因:
You're probably running into the fact that MYSQL closes connections which have been open "too long".
Probably if you make the request to the server again, you'll find that it works because the connection is reopened.
解决方法:
One way to deal with this is to add the following to your context.xml Resource:
validationQuery="select 1"
(基于mysql)
validationQuery="select
1 from dual" (基于oracle)
代价:
This causes a very cheap test query to always be run first; if the connection has been closed, this gets the failure,
and
then a new connection is opened.
细想下原来用weblogic jdbc jndi的配置有一个专门的配置项来配置这个test query,配置tomcat时粗心大意了 :(
[2015-04-30 11:15:46,939 ERROR [com.tencent.vsuning.aop.LogAdvice] - org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
Data source rejected establishment of connection, message from server: "Too many connections"] 数据库连接池耗尽异常...
error log: ( org.springframework.dao.RecoverableDataAccessException: PreparedStatementCallback; SQL [select user_id,login_name from t_sys_user where login_name=? and password=?]; The last packet successfully received from the server was1290665 seconds ago.The
last packet sent successfully to the server was 1290665 seconds ago, which 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.; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server
was1290665 seconds ago.The last packet sent successfully to the server was 1290665 seconds ago, which 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. )
数据源是用tomcat dbcp 基于jndi配置管理的,查了下,如下:
原因:
You're probably running into the fact that MYSQL closes connections which have been open "too long".
Probably if you make the request to the server again, you'll find that it works because the connection is reopened.
解决方法:
One way to deal with this is to add the following to your context.xml Resource:
validationQuery="select 1"
(基于mysql)
validationQuery="select
1 from dual" (基于oracle)
代价:
This causes a very cheap test query to always be run first; if the connection has been closed, this gets the failure,
and
then a new connection is opened.
细想下原来用weblogic jdbc jndi的配置有一个专门的配置项来配置这个test query,配置tomcat时粗心大意了 :(
[2015-04-30 11:15:46,939 ERROR [com.tencent.vsuning.aop.LogAdvice] - org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
Data source rejected establishment of connection, message from server: "Too many connections"] 数据库连接池耗尽异常...
相关文章推荐
- tomcat dbcp 基于jndi当配置java.sql.SQLException: Already closed
- Tomcat配置JNDI提示:org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'oracle
- tomcat6.0中配置JNDI的DBCP连接及maxIdle ,MaxActive,maxWait介绍
- Tomcat 6.0配置数据源(DBCP)和JNDI使用
- java使用Sqlite 出现类似java.sql.SQLException: no such table: employee错误
- Tomcat 6.0配置数据源(DBCP)和JNDI使用
- java.sql.SQLException: ORA-00917: 缺少逗(log4j在数据库中插入相应信息时出现了此错误)
- Struts2使用json-plugin出现java.sql.SQLException: Positioned Update not supported异常
- J2EE 使用p6spy查看JAVA程序中执行的SQL,TOMCAT配置
- 配置Tomcat时出现"JAVA_HOME should point to a jdk not a jre”
- 在Tomcat中配置SQL的JNDI连接
- JNDI(Java 命名和目录接口)(三)---- Tomcat中配置和使用JNDI
- Tomcat 6.0配置数据源(DBCP)和JNDI使用
- Tomcat启动报java.sql.SQLException:不支持的特性
- tomcat 连接池泄露的问题:org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted, cause:java.util.NoSuchEleme
- tomcat dbcp jndi 配置
- ST测试时操作量过大出现java.sql.SQLException: No more data to read from socket异常
- Tomcat 部署 时 java.sql.SQLException: No suitable driver found for jdbc:sqlserver 我是怎么解决的
- Java开发(2) - Tomcat配置JNDI数据源
- “java.sql.SQLException: ORA-00604: 递归 SQL 级别 1 出现错误”的解决办法