0 Replies Latest reply on Oct 20, 2003 4:19 AM by kynix

    can't create a new connection

    kynix

      I have configured a datasource in jboss, and set the max-pool-size to 5000, then I start 100 threads, each invokes a finder method on a BMP. But it can be seen in the console that when the number of connection exceeds 60, no more connections could be created.
      This is my finder method:
      PreparedStatement pstmt = null;
      Connection conn = null;
      Vector v = new Vector();

      try {
      System.out.println("ejbFindByOwnerName(" + name + ") called");

      /*
      * Acquire DB connection
      */
      conn = getConnection();

      /*
      * Find the primary keys in the DB
      */
      pstmt = conn.prepareStatement("select id from accounts where ownerName = ?");
      pstmt.setString(1, name);
      ResultSet rs = pstmt.executeQuery();

      /*
      * Insert every primary key found into a vector
      */
      while (rs.next()) {
      String id = rs.getString("id");
      v.addElement(new AccountPK(id));
      }

      /*
      * Return the vector of primary keys
      */
      return v;
      }
      catch (Exception e) {
      throw new FinderException(e.toString());
      }
      finally {
      /*
      * Release DB Connection for other beans
      */
      try { if (pstmt != null) pstmt.close(); }
      catch (Exception e) {}
      try { if (conn != null) conn.close(); }
      catch (Exception e) {}
      }

      getConnection() is a method to get a connection from the datasource:
      try {
      Context ctx = new InitialContext();
      javax.sql.DataSource ds = (javax.sql.DataSource)
      ctx.lookup("ejbDataSource");
      return ds.getConnection();
      }
      catch (Exception e) {
      System.err.println("Could not locate datasource! Reason:");
      e.printStackTrace();
      throw e;
      }

      I use MS SQLServer2000 and JBoss3.2.2RC4. Who can tell me why? thanks