How to connect jmeter with database by using mysql-connector-java? - mysql

I am using phpMyAdmin version 5.7.15 and database mysql-connector-java version 5.1.40, but I am unable to connect the database with jmeter3.0. Could you please advise?

Add your driver in jmeter/lib folder
Then add a JDBC Connection Configuration and fill in:
Database URL: https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html
JDBC Driver class: com.mysql.jdbc.Driver
login and password
Variable Name will identify the connection
Then add a JDBC Request under a Thread Group
and fill in:
Variable Name : same value as the one in JDBC Connection Configuration
The other fields which depend on what you want to do
Read this tutorial:
https://jmeter.apache.org/usermanual/build-db-test-plan.html
If you're looking to learn jmeter correctly, this book will help you.

Related

Cannot create JDBC driver of class 'com.mysql.jdbc.Driver' for connect URL 'jdbc:mysql//10.0.1.86/mp_gws'

SO I am trying to connect to Mysql through JMeter and this error comes up everytime. I am using Mysql through VPN and while running the test plan I am already logged in into VPN. I have already added the jar to lib folder of JMeter and the path to the jar file to Test plan. Please Help!!!
Add the jar file with latest version and give proper path in jdbc connection configuration. as jdbc:mysql://192.168.0.00:3306/db_name. Using this connection configuration fixes the problem for me.
Your connection string is malformed, according to Driver/Datasource Class Names, URL Syntax and Configuration Properties for Connector/J it should be something like:
jdbc:mysql://[host1][:port1][,[host2][:port2]]...[/[database]][?propertyName1=propertyValue1[&propertyName2=propertyValue2]...]
So you need to amend your JDBC URL to:
jdbc:mysql://10.0.1.86:3306/mp_gws
Also make sure you have Connector/J jar somewhere in JMeter Classpath. Make sure you restart JMeter to pick the .jar up.
Check out MySQL Database and JMeter - How to Test Your Connection article for more detailed steps if required.

Connecting to a MySQL db with the anylogic objects

I'm trying to connect to a local MySQL database, with the anylogic object "database".
I'm using the type: "Other Database", and the connection URL: "Server=localhost;Database=anylogicdata;"
but I constantly get a RuntimeException saying: "not suitable driver found"
The help file says that you have to install the driver, but i don't know which or if it is my connection URL that is the problem.
Does anyone have some pointers to help me along the way?
You need a JDBC driver to be able to connect to a MySQL server from Java (that AnyLogic is based on) and you can find one here. After you have installed the driver you should find it in the list of available JDBC drivers in AnyLogic. The name should be com.mysql.jdbc.Driver if you chose the suggested one.
First you have to download and add the mysql-connector-java-*.jar file to the anylogic-project.
Then you have to type com.mysql.jdbc.Driver into the JDBC driver dropdown box. finally the connection string should look something like
jdbc:mysql:[host/db]?:[port]
another thing I found that might be helpfull to others, is that you can get the java connection from the anylogic db object: database.getConnection() this is very usefull if you want to create your own query. eg create a bulk insert instead of the single insert that Anylogic provides.

Connecting to a MySQL Database with Java to insert data in table

I have a problem inserting data to my mysql database table. I have an error :
Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Could not find output table 'book'.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6956)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7113)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3109)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:337)
at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:287)
at connectTest.ConnectTest.insertPerson(ConnectTest.java:55)
at connectTest.ConnectTestDemo.main(ConnectTestDemo.java:16)
Java Result: 1
I don't know why could not find my table.
I have created that in mysql database.
Please provide your source code and configuration file so that I can help you better.
Can you correctly connect to the database? You said you are using MYSQL database but I see you are using MS Access ODBC driver for the connection. If that is the case I recommend you use the MYSQL JDBC driver which you can download from
http://dev.mysql.com/downloads/connector/j/
If you can connect to the database correctly, then you may have not set your database schema (database name) properly.
Please provide your source code and configuration file so that I can help you better.
For an example of how you should configure db using pure JDBC have a look at this link:
http://www.tutorialspoint.com/jdbc/jdbc-insert-records.htm
Basically you provide a connection url in the format jdbc:mysql://[MySQLServer_DOMAIN_NAME_OR_IP_ADDRESS]:[PORT]/[DB_NAME].

Unable to perform a JDBC request for phpmyadmin database (No suitable driver found for jdbc:mysql://localhost:3306/ck)

I am unable to perform a JDBC request to database in phpMyAdmin. I'm using Xampp just to learn how to perform a JDBC request using Jmeter.
This is the configuration I have used in the JDBC config element(Jmeter version is 2.10)
variable name: mydb
JDBC URL:jdbc:mysql://localhost:3306/ck -- where ck is the name of the database
JDBC Driver Class: com.mysql.jdbc.driver
Username: c
Password: c
the user has all privileges on the database.
I have set the same variable name in JDBC request and using a simple select query select * from table1
But when I ran the test, I got the following error
No suitable driver found for jdbc:mysql://localhost:3306/ck
I have already extracted the JDBC driver for mysql in the lib folder
mysql-connector-java-5.0.8-bin
This is the Driver.
Is there something I am missing. the java version I am using is 1.7.0_45-b18?
I tried a lot of things and saw similar issues but previous solutions did not fit.
Class names are case sensitive.
Change:
JDBC Driver Class: com.mysql.jdbc.driver
To:
JDBC Driver Class: com.mysql.jdbc.Driver
And mysql-connector-java-5.0.8-bin is no the Driver class. But mysql-connector-java-5.0.8-bin.jar is a java class library that allows to communicate with MySQL.
Make sure that this mysql-connector-java-5.0.8-bin.jar exists in the lib path of the application in your Java IDE.

GlassFish connection pool

i put mysql driver into glassfish/admin1/lib and i get this error on trying make a connection with GlassFish 3.1.2
Ping Connection Pool failed for SimpleCRUD_ConnectionPool. Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlDataSource Please check the server.log for more details.
Hare the configuration:
Pool Name: SimpleCRUD_ConnectionPool
Resource Type: javax.sql.DataSource javax.sql.XADataSource
Datasource Classname: com.mysql.jdbc.Driver
has someone any idea?
A Driver and a DataSource are not the same. It looks from your configuration that you're setting a Driver class as the DataSource classname?
Do you really need XA? Are you doing any distributed transaction?
If so, set the data source to com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
If not, select a regular DataSource type and then set the classname to com.mysql.jdbc.jdbc2.optional.MysqlDataSource
For starters, the path where you have placed your driver does not look correct. For details on administering database connectivity in Glassfish 3.1.2 please see
12 Administering Database Connectivity
Also in that guide you will find a section installing the MySQL Server Database Type 4 Driver
If you need additional help, please post a screen capture of your JDBC resource and JDBC connection pool configuration or if you used it the asadmin command you used to create it.
-Noah
No, you just lack mysql lib, just find and download mysql-connector-java-5.x.x-bin.jar copy to E:\Projects\glassfish3.1.1\glassfish\lib then restart server and enjoy !!!