Database (MSSQL) Testing using JMeter

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 on configuring and running JMeter Database Testing. We will create a simple test plan to test an MSSQL database server, but you can use any database.

Table of Contents

What is a Test plan?

A test plan is a step-by-step plan that JMeter executes. A good tester uses one or more Thread Groups within a complete test plan.

What is the Thread Group?

Basic element of the test plan within JMeter is called Thread Group. It consists of various test elements like logic controllers, sample-generating controllers, listeners, timers, assertions, and configuration elements.

What is JDBC Connection configuration?

The full form of JDBC is Java Database Connectivity. It is an API that helps you connect with the database and execute queries. This API uses JDBC drivers to make a connection with a database. When the tester sets up a JDBC drive, defines a JDBC connection pool, and registers JDBC resources that are used by the application is called JDBC configuration.

What is JDBC request?

The JDBC Request test sends a database query and returns the result. You need a JDBC connector in the Ext/bin directory for each database type you want to use.

Configuring JMeter

Download the JMeter and configure the environment setting. The JDBC driver is needed for JMeter to connect with the MSSQL Server database. You can download the latest version of the JDBC driver here - https://learn.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-ver16 Open the downloaded archive and find the file named “mssql-jdbc-6.X.X.X.jar”. Copy the jar to the lib directory of JMeter.

Configuring JMeter Steps:

1. How to Add a thread group in Test Plan

  • Right-click on Test Plan.
  • Select Add → Threads (Users) → Thread Group.
  • Thus, the thread group gets added under the Test Plan node.

how-to-add-thread-group-in-test-plan.png

2. How to add JDBC Connection configuration?

  • Right-click on Thread Group
  • Go to Add and the “Config Element”.
  • Then Select the “JDBC Connection configuration.”

how-to-add-jdbc-connection-configuration.png

3. How to configure a “JDBC Connection configuration”:

  • Add variable Name Bound to Pool name like “Test.”
  • Add Database Connection Configuration
  • Database URL − jdbc:mysql://localhost:3306/tutorial.
  • JDBC Driver class: com.mysql.jdbc.Driver.
  • Username: root.
  • Password: ********* for root. 

how-to-configure-jdbc-connection-configuration.png

4. How to add a JDBC Request and execute the query?

  • Right Click on “Thread Group,” and go to the “Add.”
  • Choose the “Sampler” menu.
  • Select "JDBC request" option to add a “JDBC request.”

how-to-add-jdbc-request.png

Example

  • Add the same name JDBC Connection configuration time variable Name Bound to Pool.
  • Simply add query.

how-to-execute-query.png

5. How to add a listener in a thread group?

  • Right-click on Thread Group, go to Listener, then add a “View Results in Table.”

(1)How to add view result table.png

Result:-Top of the menu, green play button to click to execute the query, and results are showing on the view result table.

(3)With Result in View table.png

Conclusion

Testing ensures the real users who will use your app in the future have a hassle-free experience. In this blog, our expert highlights how to test the database app on JMeter in terms of performance and reliability. The blog provides step-by-step details with some basic definitions of app testing.

About Author

guest author Mayur RathodMayur Rathod is currently working as a Sr. Quality Assurance Analyst in PixelQA - one of the best QA testing company in India. He started his journey in 2014. He started his career as a .net developer but he doesn't find any challenge in it, so he moves to the QA field.

He believes in taking challenges in professional life. If the future, he wants to be an expert in Load performance testing, Database testing, and automation.