1 Reply Latest reply on Aug 17, 2005 3:09 PM by Adrian Brock

    Problems to return a connection to ConnectionPool

    Alexandre Barbosa Newbie

      I've searched through the forums, and I could see that this problem was faced by older versions of JBoss. I'm using the version 4.0.2

      I've built an EJB to insert an entity to a table in our Oracle DB (version, and it's working fine, including the correct behaviour for close connections (returning the connection to ConnectionPool).

      Now I'm building another EJB that performs a select on a table from this same DB. But in this case, I can only perform as many calls as the number of maximum connections setted for my datasource.

      The only difference from both cases is that in the first, all work is done by non-EJB classes in my application (the EJB only calls a method from a business class), while in the second I'm doing all work in the EJB class.

      Below is the oracle-ds.xml being used by my application (deployed on default/deploy)

       <connection-property name="autoCommit">false</connection-property>

      Next, the way I've configured the beans (in ejb-jar.xml)
       <!-- EJBs da aplicacao -->

      And now, the way I'm handling the connection in both cases;

      1. the working bean
       Connection conn = null;
       try {
       conn = ds.getConnection();
       IOrganismDAO organismDAO = OrganismDAO.getInstance();
       organismDAO.saveOrganism(conn, organism);
       } catch (SQLException sqle) {
       if (logger.isErrorEnabled())
       logger.error("Erro apos gravacao de organismo: "
       + sqle.getMessage());
       throw new BOException(sqle.getMessage(), sqle.getCause());
       } finally {
       try {
       } catch (Throwable t) {
       if (logger.isWarnEnabled()) {
       logger.warn("Erro ao fechar conexao com banco de dados\n"
       + t.getMessage() + "\n");

      2. the not working
       Connection conn = null;
       PreparedStatement pstmt = null;
       ResultSet rs = null;
       try {
       conn = ds.getConnection();
       pstmt = conn
       .prepareStatement("SELECT u.id_pessoa" + " FROM usuario u"
       + " WHERE u.senha = ?");
       pstmt.setString(1, password);
       rs = pstmt.executeQuery();
       if (rs.next()) {
       userID = rs.getInt("ID_PESSOA");
       // Fechando objetos de busca
       } catch (SQLException sqle) {
       throw new RemoteException(
       "Erro ao buscar dados de login no banco de dados: " +
       } finally {
       try {
       } catch (Exception e) {
       System.out.println("Erro ao fechar conexao");

      What I've seen is that my application can't return the connection to the ConnectionPool in the second case, but does in the first, allowing the connection reuse. The error I get is the following (extracted from my log)

      No ManagedConnections available within configured blocking timeout ( 30000 [ms] ); - nested throwable: (javax.resource.ResourceException: No ManagedConnections available within configured blocking timeout ( 30000 [ms] ))

      Can someone give me any hint on this?