2 Replies Latest reply on Dec 18, 2006 1:51 PM by lilili

    No ManagedConnections available

    lilili

      Hi,

      I use the following code in an ejb to database query:

      try {
      InitialContext ctx = new InitialContext();
      SessionFactory sessionFactory = (SessionFactory) ctx.lookup(sessionFactoryName);
      Session s = sessionFactory.getCurrentSession();
      // using s to do some queries
      ...
      // s.connection.close(); I even use this to explicitly close the connection
      s.close();
      }
      ...

      I do call session's close() method to release the connection. But I got "No ManagedConnections available" error when my jsp page queries reach the max connection pool size.
      I'v seached the forums but could not found an answer really resolve the problem.

      Could anyone please help this problem? Thx!!!


        • 1. Re: No ManagedConnections available
          vickyk

          Couple of options can cause this
          1) If your application have long running SQL's that is making the connections to be held for more time , while the SQL's are running for long time there are clients asking for more connections which are not available.
          2) You application is causing the connection leak. Close the connection in the finally block rather than in the try , that is correct usage .

          • 2. Re: No ManagedConnections available
            lilili

            vickyk,

            Thanks a lot! I follow your suggestion to put session.close() into finally block. It worked.