How To Do Database Testing with JMeter

Create a basic JMeter database test script against MySQL Database

Table of Contents

Introduction

In this ‘How-To’, You will be guided to perform a database load test using JMeter. We will be installing Apache JMeter to perform the test. You can download Apache Jmeter from this link as your first step and keep it ready for further steps to follow where we shall be creating, running and analyzing simple demo-based database test script using JMeter.

System Requirement

We would be using the following tools for this exercise:

  • Apache JMeter 5.2.1
  • Mysql-connector-java-8.0.20
  • MySQL Database (local install or cloud provisioned instance from db4free.net)
  • We are running these exercises on local windows OS machine.

1
Step 1: Launch Jmeter.

blank

You can run JMeter using the “ApacheJMeter.jar” file which is in the “bin” folder. Here is a screenshot of JMeter GUI :

2
Step 2: Download MySQL Connector

blank

We use the Mysql database to create our testing Database. First, you have to connect the MySQL database with JMeter using  MySQL connector. First, navigate to MySQL Website and download the zip folder as shown in the image below :

3
Step 3: Unzip and save MySQL Connector

Extract the zip folder and Copy “Mysql-connector-java-8.0.20.jar” file (Version may differ) from the folder and paste it into the “lib” folder of JMeter.

4
Step 4: Now Restart JMeter

Restart the JMeter so that it will work with the library provided by MySQL connector.

5
Step 5 : Create JMeter Thread Group

blank

Right-click on the Test Plan.Click “Add > Threads(Users) > Thread group” .

6
Step 6: Setup Thread Group

blank

Give a name to your Thread Group and adjust “Thread Properties” as required.

7
Step 7 : Add JDBC Config Element for JMeter

blank

Add JDBC Connection Configuration By following the steps : “ Add  > Config Element > JDBC Connection Configuration “

8
Step 8: Setup database configuration

blank

You have to fill the Database Connection Configurations as below. The Database URL  will be the location of your created database. I have used db4free.net to create the SQL database. Select MySQL driver class for JDBC Driver Class. Enter the username and password of the database in the Username and Password fields. Give the variable name as “testdb” for the created pool field.

The jdbc:mysql://[host1][:port1][,[host2][:port2]]...[/[database]] is the common format for giving your database URL. jdbc:mysql:// “ is an unchanged sequence in JMeter when specifying MySQL database address. The hostname and port name will be emailed after you create the database with db4free.net.
blank

9
Step 9: Add JDBC Request Sampler in JMeter

blank

To work with data from the database, You need to Add JDBC Request. So add JDBC Request By Clicking  Add > Sampler > JDBC Request as in the image below :

10
Step 10: Prepare SQL query

You can type and execute the SQL query in the SQL Query section. Select all data from the table by typing the SQL below. Persons is the table name of the database. Select the Query Type as “Select Statement”.

Select * from persons;

11
Step 11: Update JDBC connection name

blank

Refer the request to JDBC Connection Configuration and give the same variable name in JDBC Connection Configuration variable name field.

12
Step 12: Add ‘Results in Table’ listner to script

blank

Add “ View Results in Table”  listener. Right-clicking on the database name and click Add > Listener > View Results in Listener.

13
Step 13: Add ‘View Results Tree’ Listner

blank

Add “View Results Tree” listener. Right-clicking on the database name and click Add > Listener > View Results Tree.

14
Step 14: Run your jmeter script

blank

Test your database performance by clicking the Run button on the menu bar.

15
Step 15: View Results Table and Tree

blank

You can observe your results from “View Results in Table” and “View Results Tree” Listeners

blank
blank

If the connection is successful, the sampler result will be given as “OK” for the “Response Message”. Check it out with your connection. You can see that the Latency of my connection is pretty high here. This is the way of checking the performance of a database with JMeter and you can get useful insights to optimize your database connection from it.

Tushar Sharma
Tushar Sharmahttps://www.automationdojos.com
Hi! This is Tushar, the author of 'Automation Dojos'. A passionate IT professional with a big appetite for learning, I enjoy technical content creation and curation. Hope you are having a good time! Don't forget to subscribe and stay in touch. Wishing you happy learning!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

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

Recent Posts

RELATED POSTS

Working with JMeter Listeners

About Listeners Listeners are used for displaying test results in JMeter. Listeners allow system engineers to analyze the responses from the testing system and monetize...

Getting Started with Apache JMeter

1. Introduction As a developer, you may have tested the functionality of your code hundreds of times during development. This is known as functional testing....

How To Create FTP Test Plan in JMeter

About File Transfer Protocol File Transfer Protocol is a widely used standard network protocol for FIle sharing between a client and server in the same...

How To Do API Testing with JMeter

Introduction Application Programming Interface is a very popular term among developers. It is simply a request provider that responds to your request. In other words,...

Â

RECENT 'HOW-TO'

How To Install Oh-My-Posh On Windows PowerShell

Oh-My-Posh is a powerful custom prompt engine for any shell that has the ability to adjust the prompt string with a function or variable. It does not...

MORE ON CODEX

FEATURED PROJECTS

SEPA Bulk File Generator and Validator

ADjo LABS PROJECT: SEPA Bulk File Generator and Validator. Supported File Types PAIN008, PAIN001, PACS003 and PACS008. Tested for supporting PAIN.008.001.001 and PAIN.008.001.002 (version 1&2). The XML...

MORE IN THIS CATEGORY

Getting Started with Selenium WebDriver

Table of Contents 1. Selenium and Selenium Web Driver 2. Setting-Up the Environment 3. Test Script with Selenium Web Driver 3.1) Creating a project 3.2) Creating...

How To Sort List in Java

Introduction A List is an interface in the Java collection framework. It can be used to store objects. Programmers often encounter scenarios where they need...

Review of Test Design Studio 2.0

While QTP offers greater flexibility to automate testing procedures, the IDE lacks certain professional features. A QTP license is expensive as well. Test Design...

How To Use Mouse and Keyboard Events with Selenium

In this tutorial, we will discuss how to use mouse click events and keyboard events with Selenium WebDriver. The mouse click and keyboard events...

CHECKOUT TUTORIALS

VBS Part 1 – Introduction and Background

At the upfront, this theoretical article might look boring to most of us but still, it is advisable to know about our scripting friend...
- Advertisement -spot_img