1

我正在使用带有休眠功能的 jsf 2.0。当我晚上退出时,我的应用程序运行良好,但每天早上我都会遇到这个异常,我必须重新启动应用程序才能使其工作。

什么会导致这个

  org.hibernate.exception.JDBCConnectionException: could not execute query
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:97)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
org.hibernate.loader.Loader.doList(Loader.java:2231)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
org.hibernate.loader.Loader.list(Loader.java:2120)
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
chennaivolunteer.common.ViewActivityBean.getFirstngo(ViewActivityBean.java:156)
sun.reflect.GeneratedMethodAccessor257.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
javax.el.BeanELResolver.getValue(BeanELResolver.java:87)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:67)
org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:142)
org.apache.el.parser.AstValue.getValue(AstValue.java:169)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
org.apache.myfaces.view.facelets.el.TagValueExpression.getValue(TagValueExpression.java:85)
org.apache.myfaces.view.facelets.component.UIRepeat.getValue(UIRepeat.java:246)
org.apache.myfaces.view.facelets.component.UIRepeat.getDataModel(UIRepeat.java:209)
org.apache.myfaces.view.facelets.component.UIRepeat._validateAttributes(UIRepeat.java:528)
org.apache.myfaces.view.facelets.component.UIRepeat.process(UIRepeat.java:578)
org.apache.myfaces.view.facelets.component.UIRepeat.encodeChildren(UIRepeat.java:1137)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:609)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:614)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:614)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:614)
org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1159)
org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:263)
org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:85)
org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:239)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:191)
org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
root cause

 com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: No operations    allowed    
 after connection closed.Connection was implicitly closed due to underlying exception/error:

这是我的 hibernate.cfg.xml

   <hibernate-configuration>
  <session-factory name="">
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="connection.url">jdbc:mysql://192.168.1.200:3306            
  /chennai_volunteers</property>
       <!-- <property name="connection.url">jdbc:mysql://localhost:330          
      /chennai_volunteers</property> -->
    <property name="connection.username">root</property>
        <property name="connection.password">root</property>
  <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
  <property name="current_session_context_class">thread</property>
     <property name="hibernate.connection.pool_size">100</property>
   <!-- start c3p0 connection properties -->
      <property name="c3p0.min_size">20</property>
    <property name="c3p0.max_size">500</property>
      <property name="c3p0.timeout">25200</property>
    <property name="c3p0.acquireRetryAttempts">30</property>
    <property name="c3p0.acquireIncrement">5</property>
   <property name="c3p0.idleConnectionTestPeriod">14400</property>
   <property name="c3p0.initialPoolSize">20</property>
 <property name="c3p0.maxPoolSize">300</property>
  <property name="c3p0.maxIdleTime">300</property>
 <property name="c3p0.maxStatements">200</property>
  <property name="c3p0.minPoolSize">10</property>
   </session-factory>
  </hibernate-configuration>

提前致谢。

4

1 回答 1

0

maxIdleTime在 c3p0 中查看MaxIdleTime的设置

如果您希望连接永远持续,您需要设置为0(默认为0)。由于您300在第二天早上将其设置为秒,因此所有空闲连接都已被剔除。

于 2012-06-05T06:22:42.453 回答