2
votes

I've been reading through the forums, the Apache JMeter guide, and BlazeMeter's The Real Secret to Building a Database Test Plan With JMeter and Using JDBC Sampler In JMeter, but I'm still kind of lost.

I need to issue a query to extract an Obj ID value from a table and pass that value into an HTTP READ Request. I've done the following setup:

JDBC Request
Variable Name: Pool-1
Query Type: Select Statement
Query: select distinct ObjId from dbo.CommonRuleSet where Name like '%ABC%';
Param. values:
Param. types:
Variable names: abcObjId
Result variable name: abcCommonRule = vars.getObject("resultObject").get(0).get("ObjId");
Query Timeout (s): 5000
Handle Result Set: Store as Object

When executed results in:
ObjId
1136682203

I'm trying to figure out how to pass in this ObjId value as a variable to append the URL.

HTTP REQUEST
database:port/applicationServer/../../crud/CommonRuleSet/????

I've tried appending using:

  1. the Variable names value: ${abcObjId}
  2. the Result Variable Name: ${abcResult}

Each time, JMeter is not translating the variable resulting in a parser error.
(e.g., http://database:port/.../.../.../crud/CommonRuleSet/${abcResult})

I'm just not understanding how to take the results of my successful query and pass it as a variable to an HTTP Request. Any insight/enlightenment is much appreciated!

1

1 Answers

3
votes

The solution was:

//database:port/.../.../.../crud/CommonRuleSet/${abcObjId_1}).

I guess I didn't go through enough BlazeMeter pages before posting my question. I found the solution on Debugging JDBC Sampler Results in JMeter.

The section explaining the difference and usage between Variable Names and Result Variable Name made all the difference. I now understand the Result Variable Name is an ArrayList of HashMaps, which I don't need in this scenario.

So I changed the Result Variable Name field
from: abcCommonRule = vars.getObject("resultObject").get(0).get("ObjId");
to: result,

Next, since I want to directly access the Variable Name 'abcObjId', I modified the variable that appends my URL
from: ${abcObjId}
to: ${abcObjId_1}.

I was so close... so close....

Thanks to dmitri-t and the folks at Blazemeter.