How to get object result set from JDBC Sampler in JMeter Beanshell

后端 未结 1 1201
礼貌的吻别
礼貌的吻别 2021-01-03 09:27

I am having trouble getting the result set object from JDBC Sampler in JMeter. The JMeter documentation says this exactly:

Result Variable Name
If specifie         


        
相关标签:
1条回答
  • 2021-01-03 09:53

    Beanshell is not Java, you need to access it a little bit differently.

    Those "diamond" brackets are not very supported by Beanshell. Please amend your code as follows:

    ArrayList result = vars.getObject("resultList");
    for (HashMap table : result) {
        for (Object column : table.keySet()) {
            log.info(column + "=" + table.get(column));
        }
    }
    

    The code above assumes that you have set resultList as a "Result Variable Name" in your JDBC Request Sampler.

    That should print query result into jmeter.log file.

    See How to use BeanShell guide for more details and kind of Beanshell cookbook.

    0 讨论(0)
提交回复
热议问题