Jmeter Database Testing | JMeter Database Test Plan - jmeter - jmeter tutorial



How to create a simple test plan to test the database server?

  • For our test purpose we use the MYSQL database server.
  • You can use any other database for testing.
  • For installation and table creation in MYSQL please refer MYSQL Tutorial.
learn apache jmeter tutorials - database testing

learn apache jmeter tutorials - database Example

Once MYSQL is installed, follow the steps below to setup the database

  • Create a database with name "WIKITECHY".
  • Create a table wikitechy_tbl.
  • Insert records into wikitechy_tbl as shown below
mysql> use WIKITECHY;

Database changed

mysql> INSERT INTO wikitechy_tbl 
     ->(wikitechy_title, wikitechy_author, submission_date)
     ->VALUES
     ->("Learn PHP", "John Poul", NOW());
	  
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO wikitechy _tbl
     ->( wikitechy _title, wikitechy _author, submission_date)
     ->VALUES
     ->("Learn MySQL", "Abdul S", NOW());
	  
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO wikitechy _tbl
     ->( wikitechy _title, wikitechy _author, submission_date)
     ->VALUES
     ->("JAVA Tutorial", "Sanjay", '2007-05-06');
	  
Query OK, 1 row affected (0.01 sec)

mysql>
  • Copy the appropriate JDBC driver to /home/manisha/apache-jmeter-2.9/lib.
jmeter tutorials - jmeter load testing - jmeter download - download jmeter - apache jmeter

Create JMeter Test Plan

Let us start the JMeter from /home/manisha/apache-jmeter-2.9/bin/jmeter.sh.

Add Users

To create a Thread group,

  • Right-click on Test Plan.
  • Select Add > Threads (Users) > Thread Group.
  • Thus, thread group gets added under the Test Plan node.
  • Rename this Thread Group as JDBC Users.
 add threadgroup in database test plan

We will not change the default properties of the Thread Group.

Adding JDBC Requests

Now that we defined our users, it is time to define the tasks that they will be performing. In this section, specify the JDBC requests to perform.

  • Right-click on the JDBC Users element. Select Add > Config Element > JDBC Connection Configuration.
  • Set up the following fields (we are using MySQL database called tutorial)
  • Variable name bound to pool. This needs to identify the configuration uniquely. It is used by the JDBC Sampler to identify the configuration to be used. We have named it as test.
  • Database URL − jdbc:mysql://localhost:3306/tutorial.
  • JDBC Driver class: com.mysql.jdbc.Driver.
  • Username: root.
  • Password: password for root.
 adding jdbc in database test

Now add a JDBC Request which refers to the JDBC Configuration pool defined above. Select JDBC Users element.

  • Click your right mouse button to get the Add menu
  • Select Add > Sampler > JDBC Request.
  • Select this new element to view its Control Panel.
  • Edit the properties as shown below
    • Variable name bound to pool. This needs to uniquely identify the configuration. It is used by the JDBC Sampler to identify the configuration to be used. Named it as test.
    • Name : Learn.
    • Enter the Pool Name : test (same as in the configuration element).
    • Query Type : Select statement.
    • Enter the SQL Query String field.
 configuration of adding jdbc database

Create Listener

  • Now add the Listener element. This element is responsible for storing all of the results of your JDBC requests in a file and presenting a visual model of the data.
    • Select the JDBC Users element
    • Add a View Results Tree listener (Add > Listener > View Results Tree).
 listener in database test
jmeter tutorials - jmeter load testing - jmeter download - download jmeter - apache jmeter

Save and Execute Test Plan

  • Now save the above test plan as db_test.jmx. Execute this test plan using Run > Start option.

Verify the Output

 code in database test
 another code in database test

 two records selection in database

In the last image, you can see that two records are selected.


This jmeter tutorial site provides you to the following keypoints on meter interview questions , apache jmeter download , apache jmeter , jmeter load testing , jmeter plugins , jmeter download , download jmeter , jmeter tutorials , load testing jmeter , jmeter summary report , jmeter apache , jmeter api testing , what is jmeter , jmeter load testing example , learn jmeter , how jmeter works , jmeter web service testing , jmeter example , jmeter load testing tutorial , install jmeter , load testing with jmeter , download jmeter for windows , performance testing using jmeter , jmeter functions , mobile app performance testing using jmeter , jmeter gui , install jmeter ubuntu , jmeter stress test , how to use jmeter

Related Searches to Jmeter Database Testing | JMeter Database Test Plan