WebLogic Server Partners' Guide
The WebLogic Server management system uses Java Management Extensions (JMX) and Managed Beans (MBeans) to configure servers. The Programming WebLogic Management Services with JMX guide provides detailed information and code samples for working with WebLogic Server MBeans.
BEA provides several JDBC MBeans that you can use to store and analyze metrics for SQL statements, prepared statements, and JDBC connection leaks. The following sections describe how to enable and use JDBC profiling. For additional information, refer to the Javadoc for the following WebLogic Server MBeans and related classes:
Before you can analyze SQL statements or connection leak profiles, you must enable profiling for the connection pool you want to observe. When profiling is enabled, the connection pool stores metrics in an external repository for later analysis.
Applications enable and disable JDBC profiling options using the
JDBCConnectionPoolMBean. In addition to providing get/set methods for standard connection pool properties,
JDBCConnectionPoolMBean provides the following methods for enabling and disabling profiling:
setConnLeakProfilingEnabled()enables or disables profiling for JDBC connection leaks. Connection leaks represent connections that were checked out of the connection pool but never returned with a
close()method. It is important to analyze the connection leak profiles, as leaked connections cannot be used to fulfill later connection requests.
setSqlStmtProfilingEnabled()enables or disables profiling for SQL statements. When this type of profiling is enabled, the connection pool stores both SQL statement text as well as the statement execution time and other metrics. You can analyze the SQL statement profile to determine which queries consume the most time in your applications.
setSqlStmtParamLoggingEnabled()enables or disables profiling for the bind parameters of prepared and callable statements. Because statement parameters can be very large, you can optionally use
setSqlStmtMaxParamLength()to limit the size of parameters that are stored in the profile.
For information on obtaining MBeans in WebLogic Server, see "Accessing WebLogic Server MBeans" in Programming WebLogic Management Services with JMX. The following excerpt shows an application that obtains the
JDBCConnectionPoolMBean and activates all profiling options. This example stores a maximum of 20 characters for each statement parameter:
Once you have enabled the desired profiling option(s), you can analyze the stored metrics using the
JDBCConnectionLeakProfile classes. Both of these profile classes can be easily obtained using the
Obtaining all profiles at once may consume considerable resources. For this reason, applications should generally retrieve only a subset of profiles at a given time. You can accomplish this by first determining the total number of profiles in storage, then retrieving profiles in smaller subsets.