0 Replies Latest reply on May 10, 2005 6:22 AM by varkon

    Connections not returned to Pool

    varkon Newbie

      // Pasted here from Hibernate.org forum

      Hibernate version: 2.1.8

      Mapping documents:
      *** hibernate-service.xml ***



      jboss.jca:service=LocalTxCM,name=OracleDS
      java:/ora/SessionFactory
      java:/OracleDS
      net.sf.hibernate.dialect.Oracle9Dialect
      3
      true
      true
      false
      25
      true

      net.sf.hibernate.cache.HashtableCacheProvider




      *** oracle-ds.xml ***


      <local-tx-datasource>
      <jndi-name>OracleDS</jndi-name> <connection-url>jdbc:oracle:thin:@192.20.10.01:1521:MYSID</connection-url>
      <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
      <user-name>sys</user-name>
      admin
      <min-pool-size>5</min-pool-size>
      <max-pool-size>50</max-pool-size>
      <blocking-timeout-millis>50000</blocking-timeout-millis>
      <idle-timeout-minutes>1</idle-timeout-minutes> <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name> <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>

      <type-mapping>Oracle9i</type-mapping>

      </local-tx-datasource>



      Code between sessionFactory.openSession() and session.close():
      boolean user_found = false;
      Session session = null;
      try {
      session = new ContextResources().getHibernateFactory().openSession();
      Query query = session.createQuery("from TerminalUser as tu where tu.TuPassword = :paswd ");
      query.setParameter("paswd",passwd);
      Iterator it = query.iterate();
      while(it.hasNext()) {
      TerminalUser tu = (TerminalUser)it.next();
      if ((tu.getId().getEmployeeId()).equalsIgnoreCase(uname)) {
      user_found = true;
      }
      }
      session.close();
      //Setting session to null, just in case...
      session = null;
      }
      catch(Exception e) {
      e.printStackTrace(); //DEBUG
      try {session.close();session = null;}catch(Exception e1) {}
      throw new DataBaseException();
      }


      Name and version of the database you are using:
      Oracle 9i v9.2.0.1.0


      JBoss version: 4.0.1sp1

      Hibernate tool: Hibernate Synchronizer

      The code above is used inside a stateless session EJB.
      It appears that even by calling session.close() the DB connection used does not return to the connection pool. I've also tried getting a connection directly from the connection pool and provide it to hibernate (in openSession() method), but no luck. My pool is only getting smaller...

      Any thoughts on what I might be doing wrong?