java.sql.SQLException:连接关闭后不允许任何操作

我已经构建了一个使用session维护的应用程序.
它使用JDBC& MySQL的.

当应用程序部署在服务器上时(Apache Tomcat 6).我可以登录退出会话.工作完全没问题.

现在我让服务器继续运行24小时.现在第二天我在输入凭据后尝试登录系统,单击“登录”按钮我在网页上收到错误,如下所示:
(这是什么原因?)

Http状态500

例外

org.apache.jasper.JasperException:在第11行处理JSP页面/login.jsp时发生异常

9:     Connection con =ConnectionProvider.getConnection();
10:     System.out.println("con "+con);
11:     con.setAutoCommit(false);
12:     Statement st = con.createStatement();
13:     ResultSet rs;
14:     rs = st.executeQuery("select * from ejduge_login where uname='" + userid + "' and pass='" + pwd +"'");


Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause 

javax.servlet.servletexception: java.sql.sqlException: No operations allowed after connection closed.
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
    org.apache.jsp.login_jsp._jspService(login_jsp.java:97)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause 

java.sql.sqlException: No operations allowed after connection closed.
    com.MysqL.jdbc.Connection.checkClosed(Connection.java:2726)
    com.MysqL.jdbc.Connection.setAutoCommit(Connection.java:498)
    org.apache.jsp.login_jsp._jspService(login_jsp.java:65)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

提前致谢!

解决方法:

我发现,关闭连接的认时间,如果它已经非活动太长,则MysqL为28800秒(8小时)(&不是34,247,052毫秒).

show global variables;

MysqL中,我将该值重置为172800秒(根据我的要求,48小时)

set global wait_timeout=172800;

它工作得很好.

非常感谢您的帮助!

相关文章

连接数据库的方式:第一种方式:ODBC:开放数据库连接是微软...
JDBCRequest 使用VariableNamesmysql:数据库连接池对象var...
 1.JDBCDBC(JavaDataBaseConnectivity):Java数据库连接技术...
1.需要jar包的支持:java.sqljavax.sqlmysql-conneter-java....
1.简介Activiti是一个业务流程管理(BPM)框架,它是覆盖了业务...
1.JDBC体系系统一组规范:接口JDBC接口(API)包括两个层次:...