Ajantha Hebbar
Ajantha Hebbar

Reputation: 11

How to load a JMeter parameter using a JDBC query

I'm trying to fetch the last id value of the database using the select query in JDBC request and I need to pass the id as the starting value for the counter. I tried adding the variable in the counter as ${variable} / ${variable_1} but nothing worked for me.

here I'm fetching the entity_id in "status" variable

here i need to pass the value of that variable to starting value of counter

How can i achieve the same?

I have tried adding ${status}, ${status_1} but both didn't work for me

Upvotes: 1

Views: 684

Answers (1)

Dmitri T
Dmitri T

Reputation: 168002

According to 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 if your JDBC PreProcessor runs successfully you should have the following variables set up:

  • ${status_#} with the value of 1
  • ${status_1} with the return value of your SQL query

The JMeter Variables which are pre-defined and created can be visualized using Debug Sampler and View Results Tree listener combination.


My expectation is that your SQL statement fails somewhere somehow, i.e. you need to remove the semicolon ; from it.

Upvotes: 1

Related Questions