First,
Download the database driver and drop it into the D:\apache-jmeter-2.13\lib\ext directory
Second, open JMeter, right-click Add- config file ->jdbc Connection Configuration
Third, set the database configuration information:
Variable name: Database variable name, This value is used in subsequent JDBC Request ;
Database URL: The format is:jdbc:mysql://host:port/{dbname};
JDBC Driver class:mysql Drive class selection com.mysql.jdbc.Driver ;
Username/password: The user name and password of the database;
Four, Thread Group Right-click Add -sampler- JDBC Request
Five, set JDBC Request Properties
Variable name: Database variable name, consistent with Variable name in JDBC Connection Configuration
Variable Names: variable name to save SQL statement return result
Vi. use of query data
The above steps are done to connect the database and query the database, then, then, how to use the results of the query?
1, the above query result variable named userId, returned is a single field value, when used, the call format is:${userid_1}, the first column of the call result set of the first row of data
2,If the return is a multi-row multi-column data set, when used, how to call?
If the query results for SQL query are:
Invoke rule:
This is stated in JMeter, when Variable Names is set to rs1,rs2.rs3, then rs1, Rs2.rs3 represents the first column in the query result set, the second column, and the third column respectively .
It needs to be set according to the actual needs, which column of data is required, if we only need the first column and the third column of data, can be written Rs1,rs3, the middle of the "," can not be omitted
Example:
when Variable Names is set to rs1,rs2,rs3, add Debug Sampler, view the results as shown, the result set contains section 1 columns, column 2 , and column 3 data for all rows
when Variable Names is set to rs1,,rs3, add Debug Sampler, view the results as, The result set contains only the data for all rows in the first and third columns
at the time of invocation, you can use ${rs3_2} to get the corresponding value of row 2 of column 3.
JMeter Connect and use MySQL data