RPM: JMeter parameterized using the JDBC Connection configuration to read data from a database and correlate variables

Source: Internet
Author: User

1. Download the mysql jar package

Download MySQL jar package

http://dev.mysql.com/downloads/connector/j/

NET Disk: Mysql-connector-java-commercial-5.1.25-bin.jar

To view the supported MySQL versions of the jar package:

Http://dev.mysql.com/doc/connector-j/en/connector-j-versions.html

View MySQL database version: SELECT version ();

Note: If the downloaded Jar package version does not support the MySQL database, you may get an error when running Jmter: no suitable driver found for jdbc:mysql//...

to be Jmeter Add Jar file

Unzip the. zip file after download and put Mysql-connector-java-x.x.x-bin.jar (example: Mysql-connector-java-commercial-5.1.25-bin.jar) in the Lib directory under the JMeter installation directory (Example: D:\Program files\apache-jmeter-2.13\lib)

2. start Jmeter, add the required originals,Sampler

Slightly

3. Add DBC Connection Configuration

Configuring components, add-on, right-click Thread groups->JDBC Connection configuration



Configuration



Description: Basic configuration items such as the upper red box selection

Database Url:jdbc:mysql://mysql_host_ip:mysql_port/mysql_db_name

JDBC Driver Class:com.mysql.jdbc.Driver

Username: Database User name

Password: Database password

4. Add JDBC Request

Add->sampler->jdbc Request to right-click Thread Group




Configuration:

Description

Variable Name: Enter the variable name to be filled in when adding DBC Connection configuration, in order to establish an association

Query Type: Set as needed, select query in the example



5. Add View results Tree

Purpose: Easy to view running results

View results tree, add-on, right-click Thread Group



6. Add a regular expression extractor

Right-click, add-on, post-processor, regular expression extractor



Configuration:



Description

Reference name : Custom input (this name is used when parameterized

Regular Expression : a regular expression used for matching, for example: username= (. +?) passwd (. +?)

Note: () the content in parentheses is the extracted content

template : The usual form is: $n $, for example: $1$$2$

NOTE: n Here is the nth extracted content, $n $ i.e. in the above regular expression, the contents of the nth parenthesis

Match Numbers ( 0 random): 0 for random, 1 for all, and 1 for positive integer n for nth extracted content.

Default: The default value to be taken when a regular match fails, usually set to null

Description of reference name :

Example 1 :

Reference Name: Name

Regular expression: username= (. +?) passwd (. +?)

Template: $1$$2$

Match number (0 for random): 1

Default value: null

Reference name: ${name_g1} represents the contents of the 1th parenthesis, ${name_g2} represents the contents of the 2nd parenthesis

Example 2 :

Reference Name: Name

Regular expression: username= (. +?) passwd (. +?)

Template: $1$$2$

Match number (0 for random): 2

Default value: null

Reference name: ${name} represents the contents of the 2nd parenthesis

Conclusion: It is said that there are multiple content to be extracted (that is, multiple parentheses), the matching number is set to 1 o'clock, and the nth parenthesis is used to obtain the ${NAME_GN}.

7. parameterization

8. Running







9. The Regular expression description:

(): Encapsulates the matching string to return.

.: Matches any string.

+: one or more times.

?: Stop after the first match is found

Original address: http://blog.sina.com.cn/s/blog_13cc013b50102wcc7.html

RPM: JMeter parameterized using the JDBC Connection configuration to read data from a database and correlate variables

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.