Sample JMX Code to retrieve JDBC Connection Pool Parameter

import java.io.IOException;
import java.util.*;

import javax.management.*;
import javax.management.remote.*;

import javax.naming.Context;

import weblogic.jndi.Environment;
import weblogic.management.*;

public class JDBCConnectionPoolProperties {

	static MBeanServerConnection connection;
	static JMXConnector connector;
	static ObjectName service;

	public static void main(String[] args) {

		try {

			JMXServiceURL serviceURL = new JMXServiceURL("t3", "localhost",
					80,
					"/jndi/weblogic.management.mbeanservers.domainruntime");
			service = new ObjectName(
					"com.bea:Name=DomainRuntimeService,Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean");

			Hashtable h = new Hashtable();
			h.put(Context.SECURITY_PRINCIPAL, "weblogic");
			h.put(Context.SECURITY_CREDENTIALS, "weblogic123");
			h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,
					"weblogic.management.remote");
			connector = JMXConnectorFactory.connect(serviceURL, h);
			connection = connector.getMBeanServerConnection();

			JDBCConnectionPoolProperties jdbcConnPP = new JDBCConnectionPoolProperties();
			jdbcConnPP.getJDBCRuntime();

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void getJDBCRuntime() throws Exception {

		ObjectName[] serverRuntime = (ObjectName[]) connection.getAttribute(service,
				"ServerRuntimes");

		int length = (int) serverRuntime.length;

		for (int i = 0; i < length; i++) {
			String name = (String) connection.getAttribute(serverRuntime[i], "Name");
			ObjectName[] jdbcRuntime = (ObjectName[]) connection.getAttribute(new ObjectName("com.bea:Name="+name+",ServerRuntime="+name+",Location="+name+",Type=JDBCServiceRuntime"),"JDBCDataSourceRuntimeMBeans");
			int jdbcLength = (int) jdbcRuntime.length;

			for (int x = 0; x < jdbcLength; x++) {
				System.out.println("nServer Name   " + name
						+ "   Datasource Name: "
						+ (String) connection.getAttribute(jdbcRuntime[x], "Name"));
				System.out.println("ActiveConnectionsCurrentCount    : "
						+ connection.getAttribute(jdbcRuntime[x],
								"ActiveConnectionsCurrentCount"));
				System.out.println("ActiveConnectionsAverageCount    : "
						+ connection.getAttribute(jdbcRuntime[x],
								"ActiveConnectionsAverageCount"));
				System.out.println("ActiveConnectionsAverageCount    : "
						+ connection.getAttribute(jdbcRuntime[x],
								"ActiveConnectionsAverageCount"));
				System.out.println("ConnectionsTotalCount            : "
						+ connection.getAttribute(jdbcRuntime[x],
								"ConnectionsTotalCount"));
				System.out.println("CurrCapacity                    : "
						+ connection.getAttribute(jdbcRuntime[x], "CurrCapacity"));
				System.out.println("CurrCapacityHighCount            : "
						+ connection.getAttribute(jdbcRuntime[x],
								"CurrCapacityHighCount"));
				System.out.println("HighestNumAvailable              : "
						+ connection.getAttribute(jdbcRuntime[x],
								"HighestNumAvailable"));
				System.out.println("HighestNumAvailable              : "
						+ connection.getAttribute(jdbcRuntime[x],
								"HighestNumAvailable"));
				System.out.println("LeakedConnectionCount            : "
						+ connection.getAttribute(jdbcRuntime[x],
								"LeakedConnectionCount"));
				System.out.println("WaitSecondsHighCount             : "
						+ connection.getAttribute(jdbcRuntime[x],
								"WaitSecondsHighCount"));
				System.out.println("WaitingForConnectionCurrentCount: "
						+ connection.getAttribute(jdbcRuntime[x],
								"WaitingForConnectionCurrentCount"));
				System.out.println("WaitingForConnectionFailureTotal: "
						+ connection.getAttribute(jdbcRuntime[x],
								"WaitingForConnectionFailureTotal"));
				System.out.println("WaitingForConnectionTotal        : "
						+ connection.getAttribute(jdbcRuntime[x],
								"WaitingForConnectionTotal"));
				System.out.println("WaitingForConnectionHighCount    : "
						+ connection.getAttribute(jdbcRuntime[x],
								"WaitingForConnectionHighCount"));
				String poolName = (String) connection.getAttribute(jdbcRuntime[x],
						"Name");
				ObjectName jdbcSystemResource = new ObjectName("com.bea:Name="
						+ poolName + ",Type=JDBCSystemResource");
				ObjectName jdbcDataSourceBean = (ObjectName) getObjectName(
						jdbcSystemResource, "JDBCResource");

				System.out.println("n Connection Pool Parameters");
				ObjectName jdbcConnectionPoolParams = (ObjectName) getObjectName(
						jdbcDataSourceBean, "JDBCConnectionPoolParams");
				Integer CapacityIncrement = (Integer) getObjectName(
						jdbcConnectionPoolParams, "CapacityIncrement");
				System.out
						.println(" CapacityIncrement                      :"
								+ CapacityIncrement);

				Integer ConnectionCreationRetryFrequencySeconds = (Integer) getObjectName(
						jdbcConnectionPoolParams,
						"ConnectionCreationRetryFrequencySeconds");
				System.out
						.println(" ConnectionCreationRetryFrequencySeconds:"
								+ ConnectionCreationRetryFrequencySeconds);

				Integer ConnectionReserveTimeoutSeconds = (Integer) getObjectName(
						jdbcConnectionPoolParams,
						"ConnectionReserveTimeoutSeconds");
				System.out
						.println(" ConnectionReserveTimeoutSeconds        :"
								+ ConnectionReserveTimeoutSeconds);

				Integer HighestNumWaiters = (Integer) getObjectName(
						jdbcConnectionPoolParams, "HighestNumWaiters");
				System.out.println(" HighestNumWaiters                     :"
						+ HighestNumWaiters);

				Integer InactiveConnectionTimeoutSeconds = (Integer) getObjectName(
						jdbcConnectionPoolParams,
						"InactiveConnectionTimeoutSeconds");
				System.out.println(" InactiveConnectionTimeoutSeconds      :"
						+ CapacityIncrement);

				Integer InitialCapacity = (Integer) getObjectName(
						jdbcConnectionPoolParams, "InitialCapacity");
				System.out.println(" InitialCapacity                       :"
						+ InitialCapacity);

				Integer JDBCXADebugLevel = (Integer) getObjectName(
						jdbcConnectionPoolParams, "JDBCXADebugLevel");
				System.out.println(" JDBCXADebugLevel                      :"
						+ JDBCXADebugLevel);

				Integer LoginDelaySeconds = (Integer) getObjectName(
						jdbcConnectionPoolParams, "LoginDelaySeconds");
				System.out.println(" LoginDelaySeconds                     :"
						+ LoginDelaySeconds);

				Integer MaxCapacity = (Integer) getObjectName(
						jdbcConnectionPoolParams, "MaxCapacity");
				System.out.println(" MaxCapacity                           :"
						+ MaxCapacity);

				Integer ProfileHarvestFrequencySeconds = (Integer) getObjectName(
						jdbcConnectionPoolParams,
						"ProfileHarvestFrequencySeconds");
				System.out.println(" ProfileHarvestFrequencySeconds        :"
						+ ProfileHarvestFrequencySeconds);

				Integer ProfileType = (Integer) getObjectName(
						jdbcConnectionPoolParams, "ProfileType");
				System.out.println(" ProfileType                           :"
						+ ProfileType);

				Integer SecondsToTrustAnIdlePoolConnection = (Integer) getObjectName(
						jdbcConnectionPoolParams,
						"SecondsToTrustAnIdlePoolConnection");
				System.out.println(" SecondsToTrustAnIdlePoolConnection    :"
						+ SecondsToTrustAnIdlePoolConnection);

				Integer ShrinkFrequencySeconds = (Integer) getObjectName(
						jdbcConnectionPoolParams, "ShrinkFrequencySeconds");
				System.out.println(" ShrinkFrequencySeconds                :"
						+ ShrinkFrequencySeconds);

				Integer StatementTimeout = (Integer) getObjectName(
						jdbcConnectionPoolParams, "StatementTimeout");
				System.out.println(" StatementTimeout                      :"
						+ StatementTimeout);

				Integer TestFrequencySeconds = (Integer) getObjectName(
						jdbcConnectionPoolParams, "TestFrequencySeconds");
				System.out.println(" TestFrequencySeconds                  :"
						+ TestFrequencySeconds);

				String TestTableName = (String) getObjectName(
						jdbcConnectionPoolParams, "TestTableName");
				System.out.println(" TestTableName                         :"
						+ TestTableName);

				String StatementCacheType = (String) getObjectName(
						jdbcConnectionPoolParams, "StatementCacheType");
				System.out.println(" StatementCacheType                    :"
						+ StatementCacheType);

				String InitSql = (String) getObjectName(
						jdbcConnectionPoolParams, "InitSql");
				System.out.println(" InitSql                               :"
						+ InitSql);

				Boolean CredentialMappingEnabled = (Boolean) getObjectName(
						jdbcConnectionPoolParams, "CredentialMappingEnabled");
				System.out.println(" CredentialMappingEnabled              :"
						+ CredentialMappingEnabled);

				Boolean IdentityBasedConnectionPoolingEnabled = (Boolean) getObjectName(
						jdbcConnectionPoolParams,
						"IdentityBasedConnectionPoolingEnabled");
				System.out.println(" IdentityBasedConnectionPoolingEnabled :"
						+ IdentityBasedConnectionPoolingEnabled);

				Boolean IgnoreInUseConnectionsEnabled = (Boolean) getObjectName(
						jdbcConnectionPoolParams,
						"IgnoreInUseConnectionsEnabled");
				System.out.println(" IgnoreInUseConnectionsEnabled         :"
						+ IgnoreInUseConnectionsEnabled);

				Boolean PinnedToThread = (Boolean) getObjectName(
						jdbcConnectionPoolParams, "PinnedToThread");
				System.out.println(" PinnedToThread                        :"
						+ PinnedToThread);

				Boolean RemoveInfectedConnections = (Boolean) getObjectName(
						jdbcConnectionPoolParams, "RemoveInfectedConnections");
				System.out.println(" RemoveInfectedConnections             :"
						+ RemoveInfectedConnections);

				ObjectName jdbcDriverParams = (ObjectName) getObjectName(
						jdbcDataSourceBean, "JDBCDriverParams");
				ObjectName jdbcProperties = (ObjectName) getObjectName(
						jdbcDriverParams, "Properties");
				ObjectName[] jdbcPropertyBeans = (ObjectName[]) getObjectName(
						jdbcProperties, "Properties");

				for (int j = 0; j < jdbcPropertyBeans.length; j++) {
					ObjectName jdbcPropertyBean = null;
					jdbcPropertyBean = jdbcPropertyBeans[j];
					String jdbcPropertyName = (String) getObjectName(
							jdbcPropertyBean, "Name");
					String jdbcPropertyValue = (String) getObjectName(
							jdbcPropertyBean, "Value");
					System.out.println("n Name & Value  "+ jdbcPropertyName + " " + jdbcPropertyValue);
				}

			}
		}
	}

	private Object getObjectName(ObjectName objectName, String attributeName)
			throws AttributeNotFoundException, InstanceNotFoundException,
			MBeanException, ReflectionException, IOException {
		return connection.getAttribute(objectName, attributeName);
	}
}

OUTPUT

Server Name AdminServer Datasource Name: PegaRULES
ActiveConnectionsCurrentCount : 0
ActiveConnectionsAverageCount : 0
ActiveConnectionsAverageCount : 0
ConnectionsTotalCount : 10
CurrCapacity : 2
CurrCapacityHighCount : 4
HighestNumAvailable : 5
HighestNumAvailable : 5
LeakedConnectionCount : 0
WaitSecondsHighCount : 0
WaitingForConnectionCurrentCount: 0
WaitingForConnectionFailureTotal: 0
WaitingForConnectionTotal : 0
WaitingForConnectionHighCount : 0

Connection Pool Parameters
CapacityIncrement :1
ConnectionCreationRetryFrequencySeconds:0
ConnectionReserveTimeoutSeconds :10
HighestNumWaiters :2147483647
InactiveConnectionTimeoutSeconds :1
InitialCapacity :1
JDBCXADebugLevel :10
LoginDelaySeconds :0
MaxCapacity :15
ProfileHarvestFrequencySeconds :300
ProfileType :0
SecondsToTrustAnIdlePoolConnection :10
ShrinkFrequencySeconds :900
StatementTimeout :-1
TestFrequencySeconds :120
TestTableName :SQL SELECT 1 FROM DUAL
StatementCacheType :LRU
InitSql :null
CredentialMappingEnabled :false
IdentityBasedConnectionPoolingEnabled :false
IgnoreInUseConnectionsEnabled :true
PinnedToThread :false
RemoveInfectedConnections :true

Name & Value user SYSTEM