Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use "Result Variable Name" in JDBC Request object of Jmeter

Tags:

jdbc

jmeter

In JMeter I added the configuration for oracle server. Then I added a JDBC request object and put the ResultSet variable name to status.
The test executes fine and result is displayed in treeview listener.

I want to use the variable status and compare it with string but jmeter is throwing error about casting arraylist to string.

How to retrieve this variable and compare with string in While Controller?

like image 586
Rajan Avatar asked Jun 19 '13 08:06

Rajan


People also ask

How can use result variable name in JMeter?

The ResultSet variable returned with JDBC request in JMeter are in the for of array. So if you want to use variable status , you will have to use it with index. If you want to use the first(or only) record user status_1 . So you need to use it like status_{index} .


3 Answers

Just used some time to figure this out and think the accepted answer is slightly incorrect as the JDBC request sampler has two types of result variables.

The ones you specify in the Variable names box map to individual columns returned by your query and these you can access by saying columnVariable_{index}.

The one you specify in the Result variable name contains the entire result set and in practice this is a list of maps to values. The above syntax will obviously not work in this case.

like image 83
Muton Avatar answered Oct 16 '22 21:10

Muton


The ResultSet variable returned with JDBC request in JMeter are in the for of array. So if you want to use variable status, you will have to use it with index. If you want to use the first(or only) record user status_1. So you need to use it like status_{index}.

like image 30
Ruchit Rami Avatar answered Oct 16 '22 21:10

Ruchit Rami


 String host = vars.getObject("status").get(0).get("option_value");
 print(host);
 log.info("----- " + host);

Form complete infromation read the "yellow box" in this link: http://jmeter.apache.org/usermanual/component_reference.html#JDBC_Request

Other util example: http://jmeter.apache.org/usermanual/build-db-test-plan.html

like image 22
Edgard Leal Avatar answered Oct 16 '22 22:10

Edgard Leal