8 Replies Latest reply on Mar 24, 2008 3:00 PM by kukeltje

    Connections never close. Two many connections exception

      I have a problem because the connections to database (mysql) are never closed, so the configurated limit is reached.

      When a processInstances is created, it's also created the connection to database, but this connection is never closed. The processInstance is ENDED, but the connection to database is still open (sleep in mysql). So, when I have 100 processInstances created, my database limit is reached.

      This is the code for processInstance :

      JbpmContext jbpmContext = this.configuration.createJbpmContext();
      try {
       processInstance = jbpmContext.newProcessInstanceForUpdate( "xx" );
       processInstance.signal();
      } finally {
       jbpmContext.close();
      }
      


      In the jbpmContext.close(); the connection it's not closed, so remains always open.

      Here my Hibernate configuration:
       <!-- JDBC connection properties (begin) -->
       <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
       <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/xxx</property>
       <property name="hibernate.connection.username">foo</property>
       <property name="hibernate.connection.password">bar</property>
       <property name="hibernate.connection.isolation">2</property>
      
       <!--
       <property name="hibernate.c3p0.acquire_increment">1</property>
       <property name="hibernate.c3p0.idle_test_period">0</property>
       <property name="hibernate.c3p0.max_size">10</property>
       <property name="hibernate.c3p0.max_statements">0</property>
       <property name="hibernate.c3p0.min_size">5</property>
       <property name="hibernate.c3p0.timeout">60</property>
       -->
      


      I also have tested the c3p0 but it's the same, the connections are never reused and so the pool limit is reached.

      In the DbPersistenceService.closeConnection method I see that the only way to close connection is when mustConnectionBeClosed = true. And mustConnectionBeClosed is true only when DataSource is defined
      if (persistenceServiceFactory.getDataSource()!=null) { mustConnectionBeClosed = true }
      .

      Any suggestion? Thanks in advanced