I want to compare 2 JDBC responses:

I have Source reponse from 1 JDBC request as below in table format:

(Source DB)JDBC Response response1:

enter image description here

(Target DB)JDBC Reponse 2:

enter image description here

I am saving the response as String in JDBC Request (in Result Variable Name)

Now how do I compare the values in each column and Print Pass when values match. Fail it when the values do not match.

Number of rows can change.

Need help with assertion code or any other way this can be achieved in Jmeter.

  • were you able to resolve this?. even i have similar requirement and I'm new to JMeter. requesting you to help me, if you have a solution. Nov 12, 2019 at 11:48
  • there in my code I want to get JDBC request variable in foreach loop, in jsr223 assertion, def result1 = vars.getObject('result1') this returns null, for me is there any way to return correct value? Apr 13, 2021 at 14:14

1 Answer 1


Assuming you define Result variable name as result1 for first JDBC Request sampler

enter image description here

and define Result variable name as result2 for the second JDBC Request sampler you would be able to compare the result sets using JSR223 Assertion and the following code:

def result1 = vars.getObject('result1')
def result2 = vars.getObject('result2')

def equal = (result1 == result2)

if (!equal) {
    AssertionResult.setFailureMessage('result1' + (result1 as String) + System.getProperty('line.separator') + 'result2: ' + (result2 as String))   
  • Thanks for the reply. Above solution will compare entire Source and Target at once. If it fails it will not show me for which record it fails. <br/> I want to compare each column in all the rows and Pass or Fail each record individually. And when the source and Target record does not match I want to print it saying SRCID1: 11 record does not match to TGTID1: 11 <br/> Really would appreciate it if you help me solve this. Feb 27, 2019 at 23:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.