JMeter If a JDBC request is made, how the response result of the request is used for the next request (that is, the legendary association), then a study is made, and the results of the study are recorded below:
1. Add "JDBC Connection Configuration" To configure some database connection information
2. Add a "CSV Data Set Config" that is used to parameterize the Where condition in the SELECT statement in subsequent JDBC requests
3. Add a JDBC Request
4. Request a test to find that the JDBC request has been successful and can see the returned results in the response data
5. So the next question is, if my next request requires a request from JDBC, how do I get the response data in JDBC?
In JMeter, you can use the regular expression extractor to implement, then how to implement, you need to add a post-JDBC "Regular expression Extractor" (the key part of the expression is ([^ "]+)), add the expression as follows
6. To verify that the response result data in JDBC is correctly obtained, the simulation adds a simple HTTP request
Successful user_id information can be seen in the view results tree of the 7.http request
Say a few more words if the SQL statement is written in select ' User_id= ' | | ' "' | | user_id | | ' "' From Sys_user b where b.user_id= ' 13707 ', the following regular expression can be used to fetch the contents after user_id=, the regular expression is: user_id= "(. +?)"
Summarize:
1. Regular expressions seem to require a good study;
2. It is now considered that it would be more convenient to achieve the results of JDBC response by BeanShell, and write a Java program to make a package to obtain the results of each return.
Extracting test data using MySQL's concat in JMeter
In the testing process, sometimes you need to query the database to obtain the desired data information, but using the Jmeter Jdbc request to query the data,
When using regular expression extraction, it is very inconvenient, at this time, you can use a number of functions to convert the query results into a convenient format, and then use regular expressions to extract.
The following example is a CONCAT function that uses Mysql
1.select CONCAT (' "Name": ', Name, ') from ' test '. ' User '
The regular expression is:"name":(. *)
2.Select CONCAT (' num= ', count (1), ') from ' test '. ' User '
The regular expression is:num= (. *)
JMeter response results after processing a JDBC request