JDBC in Java Mission Control
By Steve Felts on Jun 20, 2013
In case you haven't tried them before, JRockit Flight Recorder (JFR) and JRockit Mission Control (JMC) are useful tools to analyze what's happening in the Java Virtual Machine (JVM) and your running application. Basically, you make a record of events and information in a defined time period and then analyze the generated jfr file with JMC. WebLogic Server 10.3.3 added support in the diagnostics component to work tightly with JMC. Part of that support is analysis of what is happening on the JDBC front and that's what I'm going to focus on here. If you want some background, read about JFR at http://docs.oracle.com/cd/E15289_01/doc.40/e15070.pdf and JMC at http://www.oracle.com/technetwork/middleware/jrockit/overview/index-090630.html.The command name to get started is jrmc.If the JVM browser is not visible, click Window -> Show View -> JVM Browser. Right click your WebLogic Server JVM in the list and select Start Console. It should look something like the following screen shot.
Now you need to record a sample for analysis. Right click the JVM connection again and select Start Recording. Select a timer period like one minute and click start. For this article, I ran a demo program OTRADE that was used at Oracle Open World 2012. It has a simple load generator that simulates updating stock values for Oracle stock. The variety of SQL statements is limited but enough to demonstrate how JFR works. A window opens to the JFR analysis when the time period is complete. I'm going to focus the analysis on JDBC events. Select the Events button on the left. Select Window -> Show View -> Event Types. Unselect Java Application, expand WebLogic, and select JDBC (minimize the Event Type window). This is what the overview tab looks like with just the JDBC events showing.
The Log tab allows you to drill into individual records.
The Trace tab allows you to see the stack trace where the SQL call was made. This can be useful if there is a misbehaving SQL statement and you want to know who is calling it.
There are a lot of other interesting areas for analysis that I won't dive into. You might want to look at Code -> Hot methods to see where time is being spent or Memory -> object statistics to see the big memory users.It's possible to load some "unsupported" plug-ins. I'd recommend the one for WebLogic. Select Help, Install Plugins, Expand, WebLogic Tab Pack, Next, Finish, and Install All. You will need to restart jrmc and select the WebLogic button on the left.
Then select the Database tab.
The default WLDF diagnostic volume is Low. You can reset it from the administrative console by selecting Environment -> Servers, clicking on the name of your server, selecting Configuration -> General, and changing the Diagnostic Volume value to Medium or High.
If you are aware of what's happening on the JVM front, you will realize that the last version of JRockit is JDK6. That's fine for WLS 10.3.6, which supports the server running on JDK6 or JDK7, but 12.1.1 moves to JDK7, which is based on HotSpot. The early versions of JDK7 on HotSpot don't have the ability to run JFR but that's coming back in Oracle JDK7 with updates greater than or equal to 7u4. I tested using the latest publicly available update at this time, 7u25, with WLS 10.3.6. You need to have a Java Advanced or Java Suite license (included in WebLogic Server EE and WebLogic Suite license). You can download it from "All Java SE Downloads on MOS [ID 1439822.1]". Of course, all of the "JRockit" names now become "Java". JRMC is now JMC (JFR remains the same). The JFR component is now gated behind switches and needs to be actively turned on. Also, HotSpot still needs to set PermGen (that isn't fixed until JDK8). So your command line will be something like
java -Xmx1024m -XX:MaxPermSize=350m -XX:+UnlockCommercialFeatures -XX:+FlightRecorder weblogic.Server
This article is a bit long but I've only scratched the surface on how to use this tool to analyze your WebLogic data source usage among the many other WLS components. I realize the pictures in this format of the blog appear small - use whatever mechanism your browser has to zoom in on them - the detail is available.
P.S. The JFR recording data is included in WebLogic Diagnostic Framework (WLDF) Diagnostic Images, and is also included in DFW incident reports. Those mechanisms can be used to capture JFR recording data as well. See Using WLDF with Oracle JRockit Flight Recorder and Configuring and Capturing Diagnostic Images.