1

I simply want to read response from jdbc sampler and use it in an http request.

I created a BeanShellAssertion Script under a jdbc request and wrote just the below code, nothing else.

if(vars.getObjects("jdbcresult1").size!=0)
{
   String jdbcresult1=vars.getObjects("jdbcresult1").get(0).get("jdbctrackingnumber1")+"";
   vars.put("trackingnumber1",jdbcresult1);
   log.info("TrackingNumber1 is: "+trackingnumber1);
}

Error:

2020-08-13 23:32:47,030 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import java.lang.Object; if(vars.getObjects("jdbcresult1").size!=0) {
String . . . '' : Error in method invocation: Method getObjects( java.lang.String ) not found in class'org.apache.jmeter.threads.JMeterVariables'

2020-08-13 23:32:47,030 WARN o.a.j.a.BeanShellAssertion: Error in BeanShellAssertion

Question1: How do you decide what should you use to write a code to read jdbcresponse value: a. beanshellassertion b. beanshellpostprocessor c. beanshelllistener

Question2: Solution to the original problem, to resolve the error ?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197

1 Answers1

0

The problem is that:

 vars.getObjects(...) 

does not exist.

It should be :

 vars.getObject(...)

See:

Also it’s better to use JSR223 Assertion:

UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116