问题描述
严重: Servlet.service() for servlet action threw exceptioncom.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: No operations allowed after connection closed.at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:888)at com.mysql.jdbc.Connection.checkClosed(Connection.java:1931)at com.mysql.jdbc.Connection.prepareStatement(Connection.java:4705)at com.mysql.jdbc.Connection.prepareStatement(Connection.java:4671)at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:597)at org.logicalcobwebs.proxool.ProxyConnection.invoke(ProxyConnection.java:68)at org.logicalcobwebs.cglib.proxy.Proxy$ProxyImpl$$EnhancerByCGLIB$$d98d67f1.prepareStatement(<generated>)at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:442)at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:368)at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:105)at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1561)at org.hibernate.loader.Loader.doQuery(Loader.java:661)at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)at org.hibernate.loader.Loader.doList(Loader.java:2145)at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)at org.hibernate.loader.Loader.list(Loader.java:2024)at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)at com.chinatravel.dao.impl.BasehibernateDAO.findByName(BasehibernateDAO.java:268)at com.chinatravel.struts.action.UserAction.userLogin(UserAction.java:71)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:597)at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)at com.chinatravel.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:40)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)at com.chinatravel.dao.LoginUserCheck.doFilter(LoginUserCheck.java:50)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)at java.lang.Thread.run(Thread.java:619)2010-11-3 16:48:49 org.apache.catalina.core.StandardWrapperValve invoke严重: Servlet.service() for servlet action threw exceptionjava.lang.OutOfMemoryError: Java heap spaceat java.util.Arrays.copyOf(Arrays.java:2882)at java.lang.StringCoding.safeTrim(StringCoding.java:75)at java.lang.StringCoding.access$100(StringCoding.java:34)at java.lang.StringCoding$StringDecoder.decode(StringCoding.java:151)at java.lang.StringCoding.decode(StringCoding.java:173)at java.lang.String.<init>(String.java:444)at java.lang.String.<init>(String.java:516)at com.mysql.jdbc.ResultSet.getStringInternal(ResultSet.java:5709)at com.mysql.jdbc.ResultSet.getString(ResultSet.java:5597)at com.mysql.jdbc.ResultSet.getString(ResultSet.java:5613)at org.hibernate.type.StringType.get(StringType.java:18)at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:113)at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:102)at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:1899)at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1372)at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1300)at org.hibernate.loader.Loader.getRow(Loader.java:1197)at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:569)at org.hibernate.loader.Loader.doQuery(Loader.java:689)at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)at org.hibernate.loader.Loader.doList(Loader.java:2145)at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)at org.hibernate.loader.Loader.list(Loader.java:2024)at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)at com.chinatravel.dao.impl.BasehibernateDAO.findByHql(BasehibernateDAO.java:279)at com.chinatravel.struts.action.AllInfoAction.findInfo(AllInfoAction.java:93)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 问题补充:pwc_pengwenchao 写道
解决方案
出现问题com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException的解决办法,检查Connection是否重复关闭。最大可能就是关闭连接后有去执行关闭操作。com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed 原因:刚使用的连接没有关闭,当第二次调用时不为空,所以直接返回一个关闭状态的连接。例如:1.静态的连接2使用某个对数据库操作的方法做逻辑运算.总的来说都是粗心造成的
解决方案二:
原因:刚使用的连接没有关闭,当第二次调用时不为空,所以直接返回一个关闭状态的连接。 http://feirou520.iteye.com/blog/282784http://odysseus-110.iteye.com/blog/441941