S2SH+mysql-软件开发实际部署问题-8个小时后提示MYSQL数据库无法连接

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: could not execute query; nested exception is org.hibernate.exception.JDBCConnectionException: could not execute query org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449) javax.servlet.http.HttpServlet.service(HttpServlet.java:690) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) com.crbt123.common.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:21)

root cause

org.springframework.dao.DataAccessResourceFailureException: could not execute query; nested exception is org.hibernate.exception.JDBCConnectionException: could not execute query org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:612) org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412) org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424) org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374) org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:917) com.crbt123.dao.hibernate.UserInfoDaoHibernate.isexistuserinfo(UserInfoDaoHibernate.java:139) com.crbt123.service.impl.UserInfoManagerImpl.isexistuserinfo(UserInfoManagerImpl.java:52) com.crbt123.web.action.IndexAction.execute(IndexAction.java:80)

如果连接闲置8小时 (8小时内没有进行数据库操作), mysql就会自动断开连接, 要重启tomcat.

不用hibernate的话, connection url加参数: autoReconnect=true >

用hibernate的话, 加如下属性:

<property name="connection.autoReconnect">true</property>

<property name="connection.autoReconnectForPools">true</property>

<property name="connection.is-connection-validation-required">true</property>

要是还用c3p0连接池:

<property name="hibernate.c3p0.acquire_increment">1</property>

<property name="hibernate.c3p0.idle_test_period">0</property>

<property name="hibernate.c3p0.timeout">0</property>

<property name="hibernate.c3p0.validate">true</property>

转载请注明:http://blog.sina.com.cn/softwaremihttp://www.cnblogs.com/ACMer/

posted on 2013-10-23 19:09  Software_King  阅读(323)  评论(0编辑  收藏  举报

导航