2

Is there any way I can add the summary report results which are generated at the end of the test in JMETER to the database ? I have created a table in in database. In this table I want to store the summary results. I am using Mysql database. How can I do this ?

Thankyou.

2 Answers 2

8

You can do it as follows:

  1. Download MySQL JDBC Driver and drop it to /lib folder of your JMeter installation
  2. Restart JMeter to pick the .jar up
  3. Add Summary Report listener to your Test Plan.
  4. Configure it to save results to some file, i.e. c:\jmeter\results.csv
  5. Add tearDown Thread Group to your Test Plan
  6. Add JDBC Connection Configuration and provide:

    • Variable Name Bound to Pool: anything meaningful, i.e. results
    • Database URL: i.e. jdbc:mysql://localhost:3306/YOUR_DATABASE_NAME_HERE
    • Database Driver Class: com.mysql.jdbc.Driver
    • Credentials
  7. Add JDBC Sampler and configure it as follows:

    • Variable Name: something which matches Variable Name in JDBC Connection Configuration, i.e. results
    • Query Type: Update Statement
    • Query: load data local infile 'c:\jmeter\results.csv' into table YOUR_TABLE_NAME_HERE fields terminated by ',' enclosed by '"' lines terminated by '\n';

This way you will be able to get results inserted automatically.

References:

Just in case if you don't know how to create a table for results with query like:

create table test (timeStamp varchar(255),elapsed varchar(255),label varchar(255),responseCode varchar(255),responseMessage varchar(255),threadName varchar(255),dataType varchar(255),success varchar(255),bytes varchar(255),grpThreads varchar(255),allThreads varchar(255),Latency varchar(255) );

See MySQL CREATE TABLE Syntax documentation for more information.

7
  • Hey thanks. I will try out these steps and let you know
    – User3091
    Apr 21, 2016 at 5:42
  • Hey I have followed your steps but getting exception for JDBC request- Variable Name must not be null in JDBC Request. What does this mean. I have checked the sheet. There is data in it.
    – User3091
    Apr 21, 2016 at 6:50
  • Hey its working. Had not specified Variable Name in JDBC sampler.
    – User3091
    Apr 21, 2016 at 13:13
  • Hey can I modify the summary listener and instead of adding to the csv file first and then adding it to database, can I directly fetch the data in JMETER only and add the values to the database ? Can I do that ?
    – User3091
    Apr 21, 2016 at 14:31
  • Dmitri T, I tried above mentioned steps. When i am Executing the test plan first time it uploading the empty file data and next time if i am again running the same test plan, It uploading the first execution data. Can you suggest any solution?
    – vikas
    Mar 20, 2017 at 14:37
1

JMeter is open source. You can even create your own listener to store the results in the DB as and when a sampler is finished. Check this to get an idea.

If you want the results while running the test, I think BeanShell Listenercan help you here. basically you place the beanshell code to log the results in the DB.

If you want the results to be uploaded after the test, Summary Report listener can be configured to log the results in a CSV file. After the test - you can either upload manually to the MySQL DB, create custom script to upload programmatically.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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