Maybe
sample_variables property can help?
1. Define something in "Variable Names" section of the JDBC Request, i.e. put session reference name there like:
2. Add the next line to user.properties file (lives in Jmeter's "bin" folder)
or alternatively pass it via -J command-line argument like:
You need to use
session_1 not
session. 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
C_#=2 (number of rows)
C_1=column 3, row 1
C_2=column 3, row 2
So given your query returns only 1 row containing 1 integer - it will live in
session_1 JMeter Variable. See
Debugging JDBC Sampler Results in JMeter article for comprehensive information on working with database query results in JMeter.
3. When test completes you'll see an extra column in .jtl results file holding your "session" value: