Naresh Kumar
Naresh Kumar

Reputation: 31

jmeter- what i need to do extra to connect with mysql database?

In my JMeter test-plan, I created a thread group and added config element with JDBC connection configuration:

Url: jdbc:mysql://localhost:3306/atmdb,
Driver class: com.mysql.jdbc.Driver
username: ****
password: ****

I also added jdbc request sampler and a view result tree listener. However after executing this test plan, I saw this error:

2015/12/18 12:53:39 INFO - jmeter.engine.StandardJMeterEngine: Running the test! 
2015/12/18 12:53:39 INFO - jmeter.samplers.SampleEvent: List of sample_variables: [] 
2015/12/18 12:53:39 WARN - jmeter.protocol.jdbc.config.DataSourceElement: Could not load driver: com.mysql.jdbc.Driver java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at java.net.URLClassLoader$1.run(URLClassLoader.java:366) 
  at java.net.URLClassLoader$1.run(URLClassLoader.java:355) 
  at java.security.AccessController.doPrivileged(Native Method) 
  at java.net.URLClassLoader.findClass(URLClassLoader.java:354) 
  at java.lang.ClassLoader.loadClass(ClassLoader.java:425) 
  at java.lang.ClassLoader.loadClass(ClassLoader.java:358) 
  at java.lang.Class.forName0(Native Method) 
  at java.lang.Class.forName(Class.java:270) 
  at org.apache.avalon.excalibur.datasource.ResourceLimitingJdbcDataSource.configure(ResourceLimitingJdbcDataSource.java:264) 
  at org.apache.jmeter.protocol.jdbc.config.DataSourceElement.initPool(DataSourceElement.java:235) 
  at org.apache.jmeter.protocol.jdbc.config.DataSourceElement.testStarted(DataSourceElement.java:108) 
  at org.apache.jmeter.engine.StandardJMeterEngine.notifyTestListenersOfStart(StandardJMeterEngine.java:214) 
  at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:336) 
  at java.lang.Thread.run(Thread.java:745)
2015/12/18 12:53:39 INFO - jmeter.gui.util.JMeterMenuBar: setRunning(true,local) 
2015/12/18 12:53:39 INFO - jmeter.engine.StandardJMeterEngine: Starting ThreadGroup: 1 : JDBC Users 
2015/12/18 12:53:39 INFO - jmeter.engine.StandardJMeterEngine: Starting 1 threads for group JDBC Users. 
2015/12/18 12:53:39 INFO - jmeter.engine.StandardJMeterEngine: Thread will continue on error 
2015/12/18 12:53:39 INFO - jmeter.threads.ThreadGroup: Starting thread group number 1 threads 1 ramp-up 1 perThread 1000.0 delayedStart=false 
2015/12/18 12:53:39 INFO - jmeter.threads.ThreadGroup: Started thread group number 1 
2015/12/18 12:53:39 INFO - jmeter.engine.StandardJMeterEngine: All thread groups have been started 
2015/12/18 12:53:39 INFO - jmeter.threads.JMeterThread: Thread started: JDBC Users 1-1 
2015/12/18 12:53:39 WARN - jmeter.protocol.jdbc.config.DataSourceElement: Could not return Connection java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/atmdb at java.sql.DriverManager.getConnection(DriverManager.java:596) 
  at java.sql.DriverManager.getConnection(DriverManager.java:215) 
  at org.apache.avalon.excalibur.datasource.JdbcConnectionFactory.newInstance(JdbcConnectionFactory.java:182) 
  at org.apache.avalon.excalibur.pool.InstrumentedResourceLimitingPool.newPoolable(InstrumentedResourceLimitingPool.java:655) 
  at org.apache.avalon.excalibur.pool.ValidatedResourceLimitingPool.newPoolable(ValidatedResourceLimitingPool.java:145) 
  at org.apache.avalon.excalibur.datasource.ResourceLimitingJdbcConnectionPool.newPoolable(ResourceLimitingJdbcConnectionPool.java:91) 
  at org.apache.avalon.excalibur.pool.InstrumentedResourceLimitingPool.get(InstrumentedResourceLimitingPool.java:371) 
  at org.apache.avalon.excalibur.pool.ValidatedResourceLimitingPool.get(ValidatedResourceLimitingPool.java:97) 
  at org.apache.avalon.excalibur.datasource.ResourceLimitingJdbcDataSource.getConnection(ResourceLimitingJdbcDataSource.java:188) 
  at org.apache.jmeter.protocol.jdbc.config.DataSourceElement$DataSourceComponentImpl.getConnection(DataSourceElement.java:286) 
  at org.apache.jmeter.protocol.jdbc.config.DataSourceElement.getConnection(DataSourceElement.java:146) 
  at org.apache.jmeter.protocol.jdbc.sampler.JDBCSampler.sample(JDBCSampler.java:85) 
  at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:434) 
  at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:261) 
  at java.lang.Thread.run(Thread.java:745)
2015/12/18 12:53:39 INFO - jmeter.threads.JMeterThread: Thread is done: JDBC Users 1-1 
2015/12/18 12:53:39 INFO - jmeter.threads.JMeterThread: Thread finished: JDBC Users 1-1 
2015/12/18 12:53:39 INFO - jmeter.engine.StandardJMeterEngine: Notifying test listeners of end of test 
2015/12/18 12:53:39 INFO - jmeter.gui.util.JMeterMenuBar: setRunning(false,local)

Can someone help me with this?

Upvotes: 3

Views: 7911

Answers (3)

Tulsi Jain
Tulsi Jain

Reputation: 109

Follow the below two steps to resolve the issue. It resolved mine

  1. Place the mysql connector jar inside apache-jmeter-3.0\lib folder
  2. Restart the jmeter

After restart only it will pick the newly placed jar files.

Upvotes: 3

Dmitri T
Dmitri T

Reputation: 168122

  1. It's better to have JMeter and MySQL server on separate machines in order to get more reliable results as they can interfere and fight for machine resources.
  2. Download MySQL JDBC Driver and drop it to JMeter's classpath (usually /lib folder of your JMeter installation). Alternatively you can configure the path on Test Plan level

    Add extra jar

  3. If you copy .jar file to /lib folder - restart JMeter to pick the .jar up
  4. I would also recommend checking out Debugging JDBC Sampler Results in JMeter guide to learn how to perform correlation, add assertions, etc.

Upvotes: 0

TestingWithArif
TestingWithArif

Reputation: 894

It seems that you have not placed correct mysql-connector file in JMeter's Lib folder. Please download this jar file and place it in Lib folder of your JMeter installation.

You can download latest mysql-connector-java-5.1.38-bin.jar from following URL: https://dev.mysql.com/downloads/connector/j/3.1.html

To properly configure MySQL JDBC connection refer to official JMeter documentation: http://jmeter.apache.org/usermanual/component_reference.html#JDBC_Connection_Configuration

Upvotes: 0

Related Questions