JMeter Connect and use MySQL data

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.