Home » JMeter Database Test Plan

JMeter Database Test Plan

by Online Tutorials Library

JMeter Database Test Plan

In this section, you will learn how to create a basic test plan to test a database server.

For our test purpose we will create a database using MySQL workbench. You can use any other database server as per your convenience. You can also refer our MySQL database tutorial https://tutoraspire.com/mysql-tutorial to learn more about database creation.

Once you have a database server on your system. Follow these steps:

  • Create a database with name “tutoraspire”.
  • Create a table “tutorials”.
  • Insert record into tutorials.

The following image shows the database with their records which we have created using MySQL work bench.

JMeter Database Test Plan

Note: You need to copy the appropriate JDBC driver to “lib” directory of apache-jmeter-4.0 folder. For example, the following image shows the respective .jar files in the C:JMeterapache-jmeter-4.0lib folder.

JMeter Database Test Plan

Create JMeter Test Plan

  • Go to your JMeter bin folder and double click on the ApacheJMeter.jar file to launch JMeter interface.
  • Select the test plan node and right click on the selected item.
  • Mouse hover on “Add” option, then elements list will be displayed.
  • Select Threads (Users) > Thread Group.
  • Rename this thread group as JDBC users.
  • The default properties of the thread group remain unaltered.

JMeter Database Test Plan

Adding JDBC requests

  • Right click on the JDBC users element.
  • Mouse hover on “Add” option, then elements list will be displayed.
  • Select Config Element > JDBC Connection Configuration.

JMeter Database Test Plan

You need to set up some important fields which will determine the proper connection between your database and JMeter. These fields include –

  • Variable name bound to pool – It identifies the configuration uniquely. This name will further be used by the JDBC Sampler to identify the configuration to be used. We have named it as test.
  • Database URL – jdbc: mysql://localhost:3306/tutoraspire
  • JDBC Driver class – com.mysql.jdbc.Driver.
  • User Name – root.
  • Password – password for root.
  • Other fields are left unaltered.

JMeter Database Test Plan

  • Right click on the JDBC users element.
  • Mouse hover on “Add” option, then elements list will be displayed.
  • Select Sampler > JDBC request.
  • JMeter Database Test Plan

  • Select this new element to view its control panel.

You need to set up some important fields. The JDBC request control panel includes –

  • Name- JMeter.
  • Enter the Pool Name – test (same as in the configuration element).
  • Query Type – Select statement.
  • Query- Enter the SQL Query string field.

JMeter Database Test Plan

Create Listener

  • Select the JDBC users element.
  • Mouse hover on “Add” option, then elements list will be displayed.
  • Select Listener > View Results Tree.

JMeter Database Test Plan

The following image shows the default View Results Tree interface.

JMeter Database Test Plan

Save and Execute Test Plan

  • Click on File > Save Test Plan as.
  • Save the entire test plan as DB_test.jmx.
  • JMeter Database Test Plan

  • Click on Run > Start to execute the test plan.

Verify the Output

Green colour against the name JMeter indicates successful execution of the Test Plan.

JMeter Database Test Plan
JMeter Database Test Plan

The Response data tab shows the records of database “tutoraspire”.

JMeter Database Test Plan

You may also like