How to save "respose data" from JDBC Request to csv file

2.9k views Asked by At

I am using CSV data config as input file in that I have HTTP request parameters stored. After hitting HTTP Request I am using JDBC request to retrieve the result from the database for same http request.

How can I store the Response data getting from JDBC request into csv. As I need to store in csv the input parameter and the response data . Is there any way where I can store it? Below is the JDBC request the result value I want to store in front of input data

JDBC Request

JDBC Response

1

There are 1 answers

4
Dmitri T On BEST ANSWER

If you are getting a single value as a result you can put something like RESULT into the "Variable Names" section

JDBC JMeter Result

After that you have 2 options:

  1. Append these 2 Variables values to JMeter .jtl results file (recommended). To do this add the next line to user.properties file:

    sample_variables=TRANSACTION_ID,RESULT_1
    

    See Sample Variables User Manual section for more details

  2. Write the files to a new CSV file. In that case you will need to add JSR223 PostProcessor and the code like (assumes Groovy language):

    def csvFile = new File("file.csv")
    
    csvFile << vars.get("TRANSACTION_ID")
    csvFile << ","
    csvFile << vars.get("RESULT_1")
    csvFile << System.getProperty("line.separator")
    

Check out Debugging JDBC Sampler Results in JMeter article to learn more about working with the JMeter's JDBC Test Elements results and result sets.