2
votes

I am using jdbc request in jmeter. I want to use result of select query as a variable so i can perform some operation in beanshell postprocessor. My sql query is-

select * from table where id = 11111 and number = ${num} order by id desc limit 1; 

I used ResultSet as a Result variable name. How can i use it in beanshell processor. And can i use this variable in other sampler?

Plz help. Thanks in advance.

1
Check the answer here. stackoverflow.com/questions/22969792/…vins

1 Answers

4
votes

You can access it as simple as vars.getObject("ResultSet"); which will return an ArrayList with query results.

vars is a shorthand to JMeterVariables class. See JavaDoc on above classes to see what you can do with them and what is the most useful in your case. Also it worth checking out How to use BeanShell: JMeter's favorite built-in component guide.

Another option is defining "Variable Names" field as

column1,column2,column3

So you will be able to access row values as:

vars.get("column1_1"); //for first row of column1
vars.get("column2_1"); //for first row of column2
vars.get("column1_2"); //for second row of column 1
etc.

Hope this helps.