tomcat dbcp 基于jndi配置时出现java.sql.SQLException: Already closed
来源:互联网 发布:多力甾醇玉米油知乎 编辑:程序博客网 时间:2024/06/16 11:18
最近观察生产环境发现一个现象,一段时间不操作,再重新操作时,数据库连接第一次会出现: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"] 数据库连接池耗尽异常...
- tomcat dbcp 基于jndi配置时出现java.sql.SQLException: Already closed
- 今天线上系统碰到个怪问题DBCP数据连接异常,java.sql.SQLException: Already closed.
- jetty服务器java.sql.SQLException: Already closed处理
- Cause: java.sql.SQLException: JZ0C0: Connection is already closed
- tomcat dbcp jndi 配置
- 基于tomcat配置JNDI
- 基于tomcat配置JNDI
- Tomcat 配置数据源(DBCP)和JNDI使用
- java.sql.SQLException: ResultSet is closed解决方法
- java.sql.SQLException: Connection is closed
- java.sql.SQLException: ResultSet is closed解决方法
- 问题解决:SQLException: org.apache.tomcat.dbcp.dbcp.DelegatingStatement with address: "com.mysql.jdbc.Statement@100363" is closed.
- Java错误提示-------java.sql.SQLException:ResultSet is closed
- Tomcat 6.0配置数据源(DBCP)和JNDI使用
- Tomcat 6.0配置数据源(DBCP)和JNDI使用
- Tomcat 6.0配置数据源(DBCP)和JNDI使用
- Tomcat 6.0配置数据源(DBCP)和JNDI使用
- Tomcat 和 Jetty 下 JNDI 配置 DBCP 连接池
- Jersey Json Deserialize - Boolean , Enum
- Using the Twisted Web Client
- Cocos2d-js官方完整项目教程翻译:十、添加音频效果的跑酷游戏
- 北京SEO培训_SEO免费公开课培训
- mac osx系统g++编译c++
- tomcat dbcp 基于jndi配置时出现java.sql.SQLException: Already closed
- linux awk命令详解
- Android开源界面库--ResideMenu用法
- 如何导入SlidingMenu——master
- 还原数据库失败,尝试 'RestoreContainer::ValidateTargetForCreation' 时,操作系统返回了错误 '5(拒绝访问。)'
- Android开发之onClick事件的两种主要形式
- java基础学习笔记——网络编程
- #33 C. Wonderful Randomized Sum ( 思维 )
- 8-20 Android学习ing