jmeter One of the important functions of is to operate the database , It is often used in interface test and performance test .

Jmeter Use scenarios of operating database ?

1. Query data in interface test , Incoming data as request parameters , Or check whether the data is written to the database correctly when asserting .

2. Interface or performance test , Concurrent requests through the interface , Batch implementation of data structure , Data recovery operations .

3. Fast implementation of the database to add, delete, modify and query .

Jmeter The process of operating the database

1. Add database driver

Drive the corresponding database jar Put in bags jmeter Of lib Under the table of contents , With mysql Drive as an example , restart jmeter take effect .


2. add to JDBC Connection Configuration( Database configuration connection pool )

Add a path : test plan -> add to -> The configuration element ->JDBC Connection Configuration picture

Parameter description

  • Variable Name: Database connection pool name , And JDBC Request Associated use .

  • Database URL: Operational database URL

  • JDBC Driver class: Database driver package , Select the corresponding driver package for different types of databases

  • Username: Database user name

  • Password: Database login password

explain : You can add many different JDBC Connection Configuration,JDBC Request Refer to... By different names .

3. Add thread group and JDBC Request


Parameter description

  • Variable Name: The database connection pool name that needs to be associated (JDBC Connection Configuration)

  • Query Type:

Select Statement: Execute a single query statement , Completed sql Don't add... At the end of the sentence “;”  Update Statement: Perform the update 、 Delete 、 Insert SQL When using Callable Statement: Execute multiple query statements .Commit: Submit Rollback: revoke 

  • Variable names: preservation sql The variable name of the execution result , Other requests or assertions use .

4. View execution sql Statement response data

Add a path : JDBC Request-> add to -> Monitor -> Look at the fruit tree

View request execution results .


jmeter Manipulate data used by different databases , Use different connection pool configurations and database driver packages .