Database load testing is used to test database applications for performance, reliability, and scalability. We will use varying user loads to identify performance issues. Load testing simulates real-life user load for the target database applications and is used to determine the behavior of the database applications when multiple users hit the applications simultaneously. This article will guide you how to configure and run JMeter Database Testing. We will create a simple test plan to test a MySQL database server, but you can use any database.

Prerequisites for JMeter Database Testing:

Before you start working with a database by using JMeter, you need to do the following:

  • Create a user who has permission to connect and perform common actions in the database.
  • Make sure the database is available for remote or local access.

Configuring JMeter:

  • The JDBC driver is needed for JMeter to connect with MySQL database. You can download the latest version of the JDBC driver here.
  • Open the downloaded archive and find the file named “mysql-connector-java-X.X.XX.jar”. Copy the jar to the lib directory of JMeter.
  • Restart JMeter to pick up the changes if it is already open.

Now the setup is complete and JMeter is ready to connect to MySQL.

For our test purposes, we will:

  • Create a database with name “demo”.
  • Create a table of usernames.
  • Insert records into usernames as shown below.

Database table setup.

Creating a test plan

  • Launch JMeter
  • Add a JDBC Connection configuration to the test plan. Right click on Test Plan → Add → ConfigElement → JDBC Connection Configuration

JMeter Setup

  • Now we have to specify the database connection properties In the JDBC Connection Configuration element.
  • The database URL is “jdbc:mysql://<DatabaseServer>:<Port>/<DatabaseName>

For the JDBC driver class, select com.mysql.jdbc.Driver. Also, enter the database username and password.

Database configuration

  • Add a thread group to Test Plan
  • Next, add a JDBC sampler to the test plan. Right click on thread group → add → sampler → JDBC Request.

JDBC Sampler setup

  • Add a listener to the test plan. Right Click on Test plan → Listeners → View Results Tree.
  • Now you can run your queries using the JDBC request sampler.
    Select your query type from the drop down menu and enter your query in the JDBC request sampler. Then, run the test.

Query setup

Query results.

You can upload this JMX file to RedLine13 to scale up your JMeter Database test.

For more information about running a JMeter test on RedLine13 follow this article Run a JMeter test with Redline13.