All JMeter basic component features are not described in this article. JMeter to link the MySQL database, first download the MySQL JDBC driver package ( Note: The driver package version must match the version of your database, the driver version is lower than the MySQL version may cause connection failure error What I'm downloading here is Mysql-connector-java-5.1.7-bin.jar.
1. Once the driver package is ready, the JDBC driver jar package needs to be introduced into the test plan. Operation steps such as:
Click Test Plan-click Browse-Check the MySQL driver Jar Pack--open
2 OK, so the driver is introduced. Next, create a new thread group:
3. Create a new JDBC Connection configuration component under the thread group, detailed configuration such as:
4. By the end of this basic configuration, you can start adding the JDBC Request test database. Create a new JDBC request with detailed steps such as:
Ok, so this is one of the simplest jmeter the script to connect to the MySQL database is basically ready, then add a listener: Look at the results tree, and then run the script, the results are as follows:
5. Of course, in practical applications, many times when we use JMeter test database, we need to use parameterization, for example, to insert some data into the database, but the inserted data are unique, then we need to parameterize the INSERT statement, JMeter The JDBC request parameterization is not different from the parameterization of the other requests: (JMeter's several parameterization methods are not described here), this article gives a simple parametric example, the other way of parameterization is the same.
A.jmeter parameterized with built-in functions: __random (1,100,) means generating a random number of 1-100
The next reference in SQL is:
There are two places that need parameterization, this time you can copy the function helper generated, replace: ${__random (1,100,)}
This is done 20 times to see the effect, set the number of threads to 20, run:
Results
You can see the results in the database:
JMeter JDBC Request connection test MySQL database