1 Reply Latest reply on Feb 27, 2004 7:55 AM by islamsakka

    Connectiion pool behavior.....

    brette

      Hey all,

      This forum is great! Lots of killer info. Thanks to all the gurus... I have aquick question regaurding the connection pooling in version 3.0.4...
      I have created a DB connection to MSSQL server 2k and I set the connection pool parameters in the service.xml as needed. My question is do I need to do anything special to use the pool? I am doing a JNDI look up on the DS. Can I assume that it is pooling....

      Here is my code....

      DataSource ds =
      (DataSource) new InitialContext().lookup("java:/MSSQLDS");
      Connection con = ds.getConnection();
      try {
      Statement stmt = con.createStatement();
      ResultSet rs = stmt.executeQuery("select * from TEST");
      while (rs.next()) {
      returnVal = (rs.getString("NAMe"));

      }
      } catch (Exception cnfe) {
      System.err.println("Unable to load MSSQL database driver!");
      System.err.println("ClassNotFoundException: " + cnfe.getMessage());
      } finally {
      con.close();
      }

        • 1. Re: Connectiion pool behavior.....
          islamsakka

          Well, you have got a DataSource instance from the connection pool you just configured, so yes, you can assume that you are using the connection pool :) .
          A good practice is to cache the handle to the connection pool DataSource(The DataSource) for performance reasons.