Database Load Testing With JMeter

JMeter is an Open Source testing software. It is 100% pure Java application for load and performance testing. JMeter is designed to cover various categories of tests such as load testing, functional testing, performance testing, regression testing, etc., and it requires JDK 5 or higher.

JMeter is one of the popular tool which is used for load testing, it will include both API and DataBase testing.

It is very easy to automate APIs to send requests and receive responses using JMeter. But there are some cases where we want to directly test the database system without interfering the HTTP calls. Apache JMeter has a built-in JDBC Request module. We can do database testing with JMeter. Let’s see how!

JMeter can connect to any database and run SQL queries concurrently. In order to do so, it’s mandatory to have necessary JDBC drivers in the lib folder of your installation.

Please note that I am taking an example of MSSQL Server but you can test any database using JMeter.

Pre-Requisites :

  • Java 8 
  • JMeter 5.0

Install Java 8 from oracle site : https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Install JMeter from apache site. https://jmeter.apache.org/download_jmeter.cgi

Unzip .zip to Specific folder


Lets Start from basics

Step 1: Launch the JMeter
cd apache-jmeter-5.1.1/bin
./jmeter   or ./jmeter.sh

Step 2: Add The Tread Group Name it whatever you like (Ex: DB Testing)


Step 3: Add JDBC Connection Configuration to Thread Group

     Right Click on The Thread Group , Config Element and Add JDBC Connection Configuration


Step 4: Configure Variable and Max No. of Connections

In the JDBC Connection Configuration, you need to specify all of your database connection configurations.


Give any Variable Name for Created pool (Example db_pool)

Variable Name for Created pool will be used in subsequent SQL query requests so it is important to provide valid name. This variable name uniquely identifies connection pools basically settings you provided in the Configurations.

Max Number of Connections : You can mention any number depending on your need. This value opens specified number of connections in the pool at one time. (For Example: 1)

Specify Database URL: jdbc:mysql://<database_serverName>/<name_of_database>

Example: jdbc:mysql://localhost:3306/shopping_db

JDBC Driver Class: com.mysql.jdbc.Driver

Enter the UserName and Password.

Step 5: Add the JDBC Request

Right Click on Thread Group -> Add -> Sampler -> JDBC Request


Varablr name of the pool: db_loop (same name we have to provide which we gave in JDBC Connection Configuration)


Now you can choose any statement like Select, Callable etc… from the dropdown.

If you want to get the data to choose select statement or to execute stored procedure choose Callable statement

Query Type: Select statement.


now Enter the SQL Query String field.

The JDBC Request looks like below


Step 6: Now Add the Listener View Result Tree


Step 7: Execute the Testplan

select the Tread Group Name(DB Testing) then click on play button as you can see in below image.



At this point of time it shows error saying “Cannot load JDBC driver class ‘com.microsoft.sqlserver.jdbc.SQLServerDriver”




To fix the above Error Follow the Below steps

1. download mysql jar from https://dev.mysql.com/downloads/connector/j/ and unzip it.

2. put jar to apache-jmeter-5.1.1/lib folder and restart JMeter


3. Now In your JMeter TestPlan browse and choose the .jar


try step 7


And that's it! you got the result now.


Facebook Page: https://www.facebook.com/DreamsAppsStore

YouTube Channel: https://www.youtube.com/channel/UCBpa57i2Y8BFh7BhH4TQ_zw

Google Play: https://play.google.com/store/apps/dev?id=8456069187984922570


Post a Comment

0 Comments