JMeter: Regular expression extractor gets the name of the column after JDBC request returned data

496 views Asked by At

I faced some issue: I use JDBC request for selecting usernames data and reuse it in the login request The JDBC request returns correct data from the table enter image description here

enter image description here

But the issue that my login request uses the column name as data, so it tries to login with the username businessId instead of the correct one. So when randomly JDBC request returns the first row which is businessId value the test returns 401 error.

enter image description here

Do you have any ideas on how can I get the correct values within JDBC request or extract values without column name?

2

There are 2 answers

0
Andrew Chichick On BEST ANSWER

Actually, the problem was in the column name which was included in the businessId results. So my JDBC Request returned the values including the column name and the column name was stored as the businessId value. For solving the issue I use ForEach Controller where Input Variable Prefix: businessId and Output variable name: currentId

4
Dmitri T On

As per JDBC Request sampler documentation

If the Variable Names list is provided, then for each row returned by a Select statement, the variables are set up with the value of the corresponding column (if a variable name is provided), and the count of rows is also set up. For example, if the Select statement returns 2 rows of 3 columns, and the variable list is A,,C, then the following variables will be set up:

A_#=2 (number of rows)
A_1=column 1, row 1
A_2=column 1, row 2

So you don't need the Regular Expression Extractor, you need to define "Variable names" like:

enter image description here

and first row value can be referenced as businessId_1, second as businessId_2, etc.

More information: Debugging JDBC Sampler Results in JMeter