jmeter: Connect to mysql database in practice

1. Check product information

Overall logic: Get the id of all products, and then parameterize the reference.
(If you don’t know how to connect to the database, you can read my last article: https://blog.csdn.net/qq_40468470/article/details/117749337 )
1. Fill in the JDBC Connection Configuration information

Insert picture description here


Fill in the JDBC request information:

Insert picture description here


Fill in foreach Controller:

Insert picture description here


Reference database data in http request:

Insert picture description here


query success:

Insert picture description here

2. Disable newly-built schools

Here we are creating a new school information, and then by calling the information in the database to disable the newly created school.
1. First of all, reference the driver package of the database first.
2. Fill in the JDBC Connection Configuration information.

Insert picture description here


3. Prepare for login and creation. Remember where to create the new name. Use parameterization to automatically change the school name:

Insert picture description here


4. Fill in the JDBC request information:

Insert picture description here


5. Get successful:

Insert picture description here


6. Quote in the request:

Insert picture description here

3. Insert table information:

Insert picture description here


This is

Insert picture description here


fine , but sometimes, if you insert multiple lines or Chinese, there will be garbled characters. The solution is as follows: allow multiple lines to be inserted: allowMultiQueries=true
Encoding format: characterEncoding=UTF-8
before and after comparison:

Insert picture description here

4. JDBC request new school information:

When we are in a newly-built school, it is impossible to have only one table of newly-built information, and it is often necessary to update the information of multiple tables. So when we create a new one, we need to have a function that allows multiple rows to be inserted. By the way, the encoding format is modified to utf-8: The

Insert picture description here


next step is to write the JDBC request information:

Insert picture description here


As can be seen from the figure, the three tables have the same data, and When these data need to be input randomly, the random parameterization method learned before will not work.
Next, we use the random variable function in the configuration element:

Insert picture description here


fill in the content as follows:

Insert picture description here

Since we have used three Query types in JDBC request, here is the end of the use of these three values:

1. Select statement
This is a query statement type; if the Query content in the JDBC Request is a query statement, select this type.

2. Update statement
This is an update statement type (including insert and update). If the Query content in the JDBC Request is an update statement, select this type. If it is a comma between each sql statement.

3. Callable statement
This is a callable statement type. As long as the grammar is correct, any statement and more can be supported. Therefore, to query or insert data, and perform multiple SQL statement operations, you must select Callable statement. To insert multiple sql statements, callable statements must be present.

Three, delete data

The principle is almost the same, to delete the newly created data:

Insert picture description here