- Official website document:
- Process overview:
- Add thread group
- Add the original configuration, JDBC Connection Configuration
- Set up database connection
- Add sampler, JDBC Request
- Set the database to be operated and the SQL statements to be executed
- Add a listener and view the result tree
- View response results
1. Prepare the environment
Because Jmeter is written in Java, during the process of operating the database, you need to add the corresponding Jar package dependency according to the type of database.
- Copy the database driver package to
jmeter/lib
2. Write jmeter script
- Add thread group
- Add the original configuration, JDBC Connection Configuration
- Add sampler, JDBC Request
- Set the statement to be executed
- Perform new operations
- To add, delete or modify, select Update Statement
- Query, select Select Statement
- Stored procedure, select Callable Statement
- Extension: read data from csv file, traverse and insert into database
- Add configuration element
- Encrypt a field before using csv data -> Use bean shell
7. Add bean shell sampler
-
Because there are 20 pieces of data in the csv, we need to set the product of the number of threads * the number of loops to 20
-
View Results
3. Parameterization
- Of course, you can also use functions and variables to replace
4. Save the select results as variables and use them as parameters for other requests.
Combined with foreach, serial requests
- Save query results in a variable
- Create logical controller, Foreach controller
- View generated variables via debug sampler
- Create JDBC sampler under ForEach controller
- Make the appropriate settings
- View the results tree viaView the results