Let's learn&succeed together with Soft Industry's blog. Read, Share, get Inspired, Gain!

Language

Company news

JMeter: databases load testing Part II

August 8, 2013

databases testing

In previous article “JMeter: databases load testing Part I” we have already discussed JDBC Connection Configuration. Today we will focus on the following issues: why do we need Connection Validation by Pool and Database Connection Configuration sections and provide steps on how to configure JMeter’s JDBC Request element.

Let’s start with the Connection Validation by Pool. These are settings, necessary to control session’s validity. Validation Query is sent regularly to the database and, in case if the session is invalid, pool will simply restart it. For example, if during the testing we restart the database, validation function will simply reload connections within the testing process.

And the last but most important section of this element is Database Connection Configuration. Using special URL, it is possible to create/set up a host, port and database name for further work.

After we have configured JDBC Connection Configuration element, it is high time to proceed with JDBC Request from Samplers section.

This is the second element of JMeter application and to configuring are needed the following steps:

Thread Group-> Add -> Sampler -> JDBC Request

Now, let’s create JDBC Request itself:
jdbc request configure
It is much easier to configure and work with this element. There are two query types you can execute against the database: Statement and Prepared Statement. What is the difference?

SQL-query is a Java-object with complicated structure. It is configured at the client’s side and resolved at the server’s side. Instead of setting up this object each time we want to test a database, it is much easier to create a kind of request template, so you could input necessary values and send it to the server.

In other words, Statement are the objects which are each time set up without using templates. Prepared Statement is a template, created once and later used to input necessary data.

Still, Prepared Statement has its drawbacks. Template is saved as cache in JVM-heap. It is necessary to create template query for each connection to the database. The more connections we use, the bigger cache size is required. During the long test, cache will turn into Old Generation and when there is sufficient memory capacity it will work faster. Otherwise, JMeter will simply stop working.There is still an opportunity run JMeter tests in parallel on different PCs. If we choose execute Statement, new objects will be created in New Generation.

Now we enter the final straight – databases testing. Add necessary reports:

Тhread Group-> Add → Listener →View Results Tree,

Thread Group-> Add → Listener → Graph Results,

Thread Group-> Add → Listener → View Results in Table

Save them Ctrl+E b Ctrl+R and view the results!