我已经构建了一个使用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;
它工作得很好.
非常感谢您的帮助!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。