Using JMETER GUI JDBC Request with Callable Statement – how do I getResultSet/MetaData? - jdbc

I’ve got a call to my database working as a SQL select statement. But I am working to call a stored procedure using JMeter for further testing. I’m strictly working off of the JMX files and do not have JMETER integrated into our main Java project at this time.
I’ve setup the JMETER GUI with the JDBC Connection Configuration and the JDBC Request. I’ve made a successful call to my database with my callable statement with my string INPUT and get the string OUTPUT parameter string.
The OUTPUT parameter string only contains information about the call (user,system, success, etc…), but none of the values/data from the table -- which are found in the ResultSet/MetaData. But I cannot figure out how to get the ResultSet or the Metadata using the JDBC Request in JMETER.
In Java, I know I use the statement and just call statement.getResultSet() and perform a loop while resultSet.next() exists. How do I do this in JMETER?
I've tried adding an additional out parameter but then my statement rejects the call, because there is only one in-parameter. I've tried a variety of JMeter Assertions - but because the main call is only returning the out parameter, I cannot grab additional data.
Query: call XXXXX.readUser(?)
Parameter Values: ${inputJSONString}
Parameter Types: INOUT VARCHAR
Variable Names: ouputJSONString
Result Variable Name: ouputJSONString
View Results Tree: Response code: 200, Response message: OK, Output variables by position: Contains the whole JSON out parameter string with user, system, and success. Returns the table column headers but no values.
I do not have errors - the call is being made successfully. I just cannot figure out how to access the Result Set from JMETER.

Don't use the same reference name for the Variable Names and the Result Variable Name as the latter one will be overwritten.
So
Change ouputJSONString to i.e. ouputJSONStringObject
Add JSR223 PostProcessor as the child of the request
You will be able to access the JMeter's representation of the ResultSet as vars.getObject('ouputJSONStringObject') (basically ArrayList of HashMaps
See Debugging JDBC Sampler Results in JMeter article for more details.
Unfortunately you cannot access the normal ResultSet as it is not exposed anywhere and being converted via private function

Related

Jmeter - How to provide variable from array to JDBC request (inside the loop controller)

Based on this thread Jmeter - Use Loop controller based on array (created from from multiple variables) I managed to use Loop controller based on the array.
Now I need to pass the each value from the array into JDBC, so I can perform select statement based on every single member of the array.
What I try is:
But I got error as:
When I try the same statement with Dammy sampler is working fine.
How to pass member from the array into JDBC inside the loop controller?
JMeter log file explicitly states Cannot invoke method length() on null object
The only place where you're invoking length() function is vars.get('array').length() which means that your ${array} variable is null (not defined), you can double check it using Debug Sampler and View Results Tree listener combination.
If the same statement works elsewhere - the only explanation I can think of is variable scope, see JMeter Scoping Rules user manual chapter for more details.

Oracle ORDS 19.2: URI Template with multiple bind variables?

-currently testing through Postman-
want a guide for this as:
i do not want to expose the parameters and their values in URL.
when using URI Template like myuri/:bindvar (single bind variable) then i can send parameters in Body.
but when creating Handler's parameters ( multiple ) i can get successful message and update sending those through Parameter tab but i can't access successfully sending those parameters through Body, parameter values are null.
the sample from oracle have 3 Templates contain bind variables in URI but all are have single bind variable.
You only need to supply the values you want to return as response
Otherwise, there's nothing special about coding a PUT handler in ORDS compared to a GET or POST - You just need to build up your PLSQL block to do the work, in this case an UPDATE, and then build out the response you want to send back to your REST API consumer.
Full example and code here

Jmeter string functions through user defined variable

I am putting some jmeter string functions in a user defined variable like below:
testdata = ${__char(165)}${__char(165)}My${__unescape(\r\n)}Deepak${__unescape(\r\n)}Play${__changeCase(Deepak\, change case,UPPER,)}
But when I am passing this value in request Body Data as ${testdata}, jmeter string functions are not resolving and I see below request in view result tree listener Request Body tab:
${__char(165)}${__char(165)}My${__unescape(\r\n)}Deepak${__unescape(\r\n)}Kumar${__changeCase(Deepak\, change case,UPPER,)}
However, when I pass above same data directly in request Body Data instead of ${testdata}, it works perfectly fine with all string functions resolving in view result tree listener request body data.
I am using Jmeter 5.3 on Windows 10 with OpenJDK 14.0.1. One of my colleagues is not facing the same issue.
I cannot reproduce your issue using latest stable JMeter 5.3:
In the vast majority of cases if JMeter doesn't do what it is supposed to be doing you can figure out the reason from jmeter.log file so it worth checking it for any suspicious entries

field name is getting changed in response data

Field name is getting changed after executing the script.
A. After executing the script,the field name is not getting displayed in response data but the parameters are displayed with slight changes.
In sampler below details are getting displayed.
Name : aura.token
Parameters : HCQAHBgEMTAwMBQCGAcxMDAwMjA5GAcxMDAwMjA5ABQCGfMQscHV8XF654tDbfY0XD3yRxaSwbvRh1oAGfMgzIG_YaBrAZdWB-IAMP_0iAQiYMHheBA3BA0SoXzWh4kA
but after execution of a script below details are getting displayed in response data.
*/{"event":{"descriptor":"markup://aura:invalidSession","attributes":{"values":{"newToken":"HCQAHBgEMTAwMBQCGAcxMDAwMjA5GAcxMDAwMjA5ABQCGfMQkaKR6n5r5QqE7gz5Qk1l1Rb67KOtiFoAGfMgtKaMHHWJZiXEOt8pU6zs1edK_Q4dQo5VL2ea8y2qi3gA"}}},"exceptionEvent":true}/*ERROR*/
It's name is "newToken". So why do you think this should not be changed?
Most probably you need to perform correlation of this field, to wit you will not be able just to record and replay the script as this "token" is being generated dynamically and has new value each time you access the application.
The main idea of the correlation is
Identifying dynamic elements. The easiest way is to record your test scenario one more time using HTTP(S) Test Script Recorder and compare the recorded scripts. All parameters which are different needs to be handled properly.
Wherever you detect a dynamic parameter look into previous sampler response data (body, headers, Cookies, URL) - the value should be there
Apply a relevant Post-Processor to the previous sampler in order to extract the dynamic value and store it into a JMeter Variable
Replace recorded value with the JMeter Variable from the previous step
You should be good to go now.

JMeter: Passing Results of SQL Query as a Variable

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:
the Variable names value: ${abcObjId}
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!
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 URLfrom: ${abcObjId}to: ${abcObjId_1}. I was so close... so close....
Thanks to dmitri-t and the folks at Blazemeter.

Resources