1 Reply Latest reply on Jun 1, 2010 12:25 PM by Peter Johnson

    How to dynamically retrieve datasource names

    Joseph Hunt Newbie

      I'm wanting to periodiacally query each registered datasource's MBean for connection statistics, using something like:



      String jmxLocation =
      "jboss.jca:name="+ jndiName + ",service=ManagedConnectionPool";
      try {
      ObjectName objectName =
      new ObjectName( jmxLocation );
      double maxConnections = Double.valueOf( String.valueOf( mbs.getAttribute( objectName, "MaxSize" ) ) );
      double inUseConnections = Double.valueOf( String.valueOf( mbs.getAttribute( objectName, "InUseConnectionCount" ) ) );
      out.println( "In use connections: " + inUseConnections );
      catch ( Exception e ) {


      What I'm wondering though, is if it's possible to dynamically retrieve each datasource's JNDI name, so that I can avoid hardcoding our various datasources.  The javadocs for ObjectName seem to indicate that only a valid domain/key/value name (like in the above code) is valid.  Is there another way of dynamically reading these JNDI names?