How to see DB connections via JMeter?

限于喜欢 提交于 2019-12-23 06:12:06

问题


M newbie to JMeter, Can we track the active DB connections via Jmeter? Is there any parameter or thing in Jmeter which can do the job easier.

Right now I am just monitoring the DB connections via terminal. Is it possible with Jmeter


回答1:


Given that your database is MySQL:

  1. Download MySQL Connector/J, extract mysql-connector-java-x.x.xx-bin.jar, drop it to /lib folder of your JMeter installation, restart JMeter
  2. Add Thread Group to the test plan. Configure it as follows:

    • Number of threads: 1
    • Ramp-up: 1
    • Loop Count: tick Forever
  3. Add JDBC Connection Configuration element. Configure it as follows:

    • Variable Name: anything meaningful, i.e. test
    • Database URL: jdbc:mysql://your_mysql_host:3306/information_schema
    • JDBC Driver Class: com.mysql.jdbc.Driver
    • provide your credentials as well
  4. Add JDBC Request Sampler. Configure it the next way:

    • Variable Name: test or what you have entered in the JDBC Connection Configuration element
    • SQL Query: select * from PROCESSLIST;
  5. Add Constant Timer. Set "Thread Delay" to be i.e. 5000
  6. Add View Results Tree listener

Above config will query MySQL server each 5 seconds and results will go to the View Results Tree listener.

If you use other RDBMS server the approach should be the same, however JDBC driver binary, driver class name, URL and SQL query will be different.

See The Real Secret to Building a Database Test Plan With JMeter for extra information on database testing with Apache JMeter.



来源:https://stackoverflow.com/questions/30148159/how-to-see-db-connections-via-jmeter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!