ssh2 connection 管理
在开发中遇到这样问题在执行查询时提示:
[org.hibernate.jdbc.ConnectionManager] finalize unclosed connection, forgot to call close() on your session?
[org.hibernate.jdbc.AbstractBatcher] closeQueryStatement exception clearing maxRows/queryTimeoutcom.microsoft.sqlserver.jdbc.SQLServerException: 该连接已关闭。at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)at com.microsoft.sqlserver.jdbc.SQLServerConnection.checkClosed(Unknown Source)at com.microsoft.sqlserver.jdbc.SQLServerStatement.checkClosed(Unknown Source)at com.microsoft.sqlserver.jdbc.SQLServerStatement.getMaxRows(Unknown Source)at org.apache.commons.dbcp.DelegatingStatement.getMaxRows(DelegatingStatement.java:234)at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:223)at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:160)at org.hibernate.loader.Loader.getResultSet(Loader.java:1685)at org.hibernate.loader.Loader.doQuery(Loader.java:662)at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:223)at org.hibernate.loader.Loader.doList(Loader.java:2147)at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2026)at org.hibernate.loader.Loader.list(Loader.java:2021)at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1455)at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:298)at com.kcyg.dao.impl.TBulBulletinDaoImpl.findHt(TBulBulletinDaoImpl.java:55)at com.kcyg.service.impl.TBulletinServiceImpl.findHt(TBulletinServiceImpl.java:67)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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)at $Proxy3.findHt(Unknown Source)at com.kcyg.web.office.manage.action.bul.TBulletinAction.findHt(TBulletinAction.java:118)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 com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:404)at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229)at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150)at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48)at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:123)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:167)at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:105)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:83)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:207)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:74)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:127)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)at org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:107)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:206)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:115)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:143)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:121)at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:170)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:123)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50)at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504)at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99)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:175)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)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:286)at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)at java.lang.Thread.run(Thread.java:619)2010-06-08 10:35:21,218 WARN [org.hibernate.util.JDBCExceptionReporter] logExceptions SQL Error: 0, SQLState: 08S012010-06-08 10:35:21,218 ERROR [org.hibernate.util.JDBCExceptionReporter] logExceptions 在 DBComms.transmit 操作期间发生异常。异常:Socket closed。上下文:(3) [Thread[http-9080-2,5,main], IO:dc15c, Dbc:19158]。2010-06-08 10:35:21,218 WARN [org.hibernate.util.JDBCExceptionReporter] logExceptions SQL Error: 0, SQLState: null2010-06-08 10:35:21,234 ERROR [org.hibernate.util.JDBCExceptionReporter] logExceptions 该连接已关闭。2010-6-8 10:35:21 org.apache.catalina.core.StandardWrapperValve invoke
<property name="hibernateProperties"><props><prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop><prop key="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</prop><prop key="hibernate.show_sql">true</prop><prop key="hibernate.format_sql">true</prop><prop key="hibernate.generate_statistics">true</prop><prop key="hibernate.jdbc.use_streams_for_binary">true</prop> <!-- 查询多条数据时会提升性能 --><prop key="hibernate.jdbc.fetch_size">50</prop><!-- 大批量删除、更新 --><prop key="hibernate.jdbc.betch_size">25</prop><prop key="hibernate.cache.use_query_cache">false</prop><prop key="hibernate.cache.use_second_level_cache">false</prop><prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop><prop key="hibernate.connection.isolation">2</prop><prop key="hibernate.hbm2ddl.auto">update</prop><prop key="hibernate.connection.release_mode">auto</prop></props></property>