Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jmeter jdbc variable names query

Again more apologies from myself for being a Jmeter newbie - I'm a little stuck with the JDBC requests - I've trawled through the posts on this site for the last 3 hours - but I can't quite find anything relevant (unless I'm missing something).

My environment: Jmeter v2.11, JDK 7, Oracle 12

It's very simple - I have a JDBC Sampler that I need to setup to use the value that is provided by a JDBC PreProcessor.

Essentially I have a JDBCPreProcessor setup to identify the next (new) record's unique reference (call it applicationID)

JDBC PreProcessor Details

Select Statement --> select max(applicationID)+1 from table;

I have a JDBC Sampler setup that I need to use the 'max(applicationID)+1' value (determined by the JDBC preprocessor)

JDBC Sampler Details

Select Statement --> select status from table where applicationID = 'max(applicationID)+1'

I am unsure how to do this. I have looked at the instructions and a lot of other Jmeter JDBC request posts, but I'm afraid I can't find the relevant info I need.

I did try including adding a 'Variable Name' of 'maxrecordidvar' in the JDBC PreProcessor and set the JDBC Sampler query --> select status from table where applicationID = maxrecordidvar

HOWEVER - this (obviously) didn't work - I get an Oracle error 'ORA-00904: "MAXRECORDIDVAR": invalid identifier'

Again, many apologies if this is a stupid question and many thanks for all/any help anyone can provide!

like image 916
sqeeky Avatar asked Feb 16 '15 15:02

sqeeky


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} .

What is JDBC PreProcessor in JMeter?

In JMeter, JDBC PreProcessor is used to fetch the data from the database which can be used in the sampler's request. Let's try to understand with an example. Consider you have a performance testing scenario where a customer needs to cancel the existing order.


1 Answers

I have simulated a concept of this using MYSQL, but the test plan is similar.

  • JDBC pre processor to get an Integer
  • Use that integer in a following JDBC request

First, the JDBC PreProcessor and JDBC Request do not just simply emit to a single variable, but rather expose a few variables based on your name. For example

  • Query : select CAST(RAND() * 242 AS UNSIGNED);
  • Variable Name : foo

Which means later on I have access to

  • ${foo_#} - the number of rows (which should be 1)
  • ${foo_1} - the value in first column row 1

This query only has one column and row, otherwise ${foo_2} would be first column row 2. More docs at JDBC Request

enter image description here

Second, to use with in my JDBC Request I had to use a Prepared Select Statement. Passing in ${foo_1} as the Parameter Value and INTEGER as the Parameter Type (I am using mysql).

enter image description here

I posted a simulated load test and JMX File.

like image 51
Richard Friedman Avatar answered Oct 14 '22 15:10

Richard Friedman