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. – Nagendra Reddy Nov 12 '19 at 11:48

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))   
| improve this answer | |
  • 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. – Mayank Parekh Feb 27 '19 at 23:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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