Software Development

NetBeans SQL Profiler – Take it for a Spin!

The upcoming release of NetBeans, currently in active development and testing, boasts plenty of new features.  A few of them include EMCAScript 6 Support, Docker Support, JavaShell Support, and SQL Profiling.  In the latest nightly builds, the SQL Profiler is now available for use, so I took it for a test spin.  In this post, I’ll run through just a few of the options available with the upcoming NetBeans SQL Profiler…I think you will be quite pleased.

The SQL Profiler allows one to instantly see which queries are causing the most contention within an application, and enables easy comparison via total running time and invocations against each of the queries that have been executed.  The tool also allows one to perform heap dump, garbage collection in the profiled process, and many other useful features.To get started with the SQL Profiler, download the latest nightly build of NetBeans, which can be done at the following URL:  http://bits.netbeans.org/download/trunk/nightly/latest/

Next, install and run the IDE, then import or select a project that utilizes a database.  Just like the other NetBeans profilers, a JVM must be calibrated for profiling before the SQL Profiler can be ran against a project that utilizes that JVM.  To perform calibration, select the project and then choose “Profile Project” from the “Profile” menu.  After a JVM has been calibrated, any project using that JVM can be profiled.  Simply select the project, and start the profiler of your choice by selecting the profiler option within the drop-down list.  In this case, I’ll choose the SQL Queries option.

nb-sqlprofiler-0
Figure 1: Configuration Page

nb-sqlprofiler-6
Figure 2: NetBeans Profiler Selection Menu

Once the profiler has been started, the application will launch and the most current SQL queries will be displayed in a chart.  In this case, I am profiling a Maven based Web application project running Java EE 7 and JPA.  When the profiler is started, the web application launches and the SQL Profiler screen is displayed.

nb-sqlprofiler-1
Figure 3: NetBeans SQL Profiler Screen

The NetBeans SQL Profiler makes it easy to see which queries have been invoked, how many times they have been initiated, and how long they took to run.  As I run my cursor over the SQL queries, the query that is under my cursor is highlighted, and I am able to click on it to expand the row and see the method invocation stack.

nb-sqlprofiler-2
Figure 4: NetBeans SQL Profiler Method Invocation Stack for Selected SQL

If I choose, I can right-click on a given query, and view the SQL.

nb-sqlprofiler-3
Figure 5: Right Click on a SQL Row

nb-sqlprofiler-4
Figure 6: View SQL Query

As mentioned at the top of the post, I have the ability to perform a heap or thread dump for a selected query, and I can even perform a garbage collection.

nb-sqlprofiler-5

The NetBeans SQL Profiler is going to be a great tool for anyone that develops applications utilizing a database backend.  Not only will it allow one to clearly see which SQL is causing the most contention within an application, but it also allows for easy comparison and provides detailed information on the underlying SQL invocations.

Download the latest build to try it out now…otherwise, it will be available with the public release of NetBeans 8.2.  The bonus is that if you try it now and find issues or have comments, you can help the developers make the Profiler even better.

Josh Juneau

Josh is an application developer and technical writer. He has authored several books for Apress, primarily focusing on Java development. Most recently, he has authored Java EE 7 Recipes, Introducing Java EE 7, and Java 8 Recipes. Josh is a member of the JCP, and he is on the JSF 2.3 Expert Group.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button