Search code examples
groovyjmeterjsr223

Fillo to get record count in Groovy failed


I use Fillo to get values from an xls. I need to get record count,

I tried to use following code:

Recordset recordset=connection.executeQuery(strQuery);
int rcount = recordset.getCount().toInteger();
vars.put(rcount, rcount);

But I'm getting error message when execute it in a JSR223 Sampler in JMeter. 12 is the correct amount of records.

javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: org.apache.jmeter.threads.JMeterVariables.put() is applicable for argument types: (java.lang.Integer, java.lang.Integer) values: [12, 12] Possible solutions: put(java.lang.String, java.lang.String), wait(), dump(), any(), wait(long, int), get(java.lang.String)


Solution

  • The key/value for JMeterVariables's put method are String type, so change type:

    Recordset recordset=connection.executeQuery(strQuery);
    String rcount = String.valueOf(recordset.getCount().toInteger());
    vars.put(rcount, rcount);
    

    if recordset.getCount() return String you can just assign it to rcount