JDBC Testing in Jmeter for DataBases: Jmeter can be used for doing a load test on different databases like Mysql, Oracle, PostgreSQL, Maria Databases. To start scripting we need to follow a few steps to configure respective DB

In this tutorial, we are going to see the configuring Mysql DB and Scripting procedure. We can use the same steps for any Database vendor

  1. Download the Mysql Driver jar from a web search for MySQL-connector-java 
  2.  Download respective Db vendor connector jar to use respective Database
  3. I am downloading the MySQL connector jar from maven repository
  • Click the highlighted link to download Mysql connector jar

NOTE: Download the jar which will support your testing DB version

  • Place the download jar file in JMETER_HOME/lib folder
  • Restart the Jmeter to take effect of your Jar.

Below are the DB and tables that we are going to test

  • Now Actual Scripting will start
  • Create a thread group
  • Add JDBC Connection Configuration from Config Element
  • Give the details like

    Variable name: which will hold DB connection object for further Queries

DataBase URL: Date URL where you DB is hosted (example URL will be like this: jdbc:mysql://localhost:3307/testdb)

JDBC Driver Classname: select the right class name from the list

user name: use the username which has access the DB you are trying to test

Password: password for the user to access DB

NOTE: Make sure your IP has access to connect the DB Server 

  • Next, Add JBDC Sampler from Sampler element
  • Creating Prepared Select Statement using pre-created connection object like below
  • In Prepared select or prepared Update for Query type, it  will allow you to send the dynamic value
  • For Select, update Statement we need to use static query to execute
  • In parameter Value, we can send value to replace in place of? dynamically value sent in parameter value will be taken using sequence
  • In parameter type, we need to mention whether it is INTEGER, VARCHAR, DATE for which we are sending  in parameter value text box

I have added CSV Data Set to send Dynamic SNo into Query like below

The file contains the value

when I Used the CSV variable request will be like below

After executing the script Below is  the output

 

Driver class name for different databases and its connection details looks like

MySQL

Driver class
com.mysql.jdbc.Driver
Database URL
jdbc:mysql://host[:port]/dbname

PostgreSQL

Driver class
org.postgresql.Driver
Database URL
jdbc:postgresql:{dbname}

Oracle

Driver class
oracle.jdbc.OracleDriver
Database URL
jdbc:oracle:thin:@//host:port/service OR jdbc:oracle:thin:@(description=(address=(host={mc-name})(protocol=tcp)(port={port-no}))(connect_data=(sid={sid})))

Ingress (2006)

Driver class
ingres.jdbc.IngresDriver
Database URL
jdbc:ingres://host:port/db[;attr=value]

Microsoft SQL Server (MS JDBC driver)

Driver class
com.microsoft.sqlserver.jdbc.SQLServerDriver
Database URL
jdbc:sqlserver://host:port;DatabaseName=dbname

Apache Derby

Driver class
org.apache.derby.jdbc.ClientDriver
Database URL
jdbc:derby://server[:port]/databaseName[;URLAttributes=value[;…]]

MariaDB

Driver class
org.mariadb.jdbc.Driver
Database URL
jdbc:mariadb://host[:port]/dbname[;URLAttributes=value[;…]]

Exasol (see also JDBC driver documentation)

Driver class
com.exasol.jdbc.EXADriver
Database URL
jdbc:exa:host[:port][;schema=SCHEMA_NAME][;prop_x=value_x]

 

 

Thanks 

Happy learning

JDBC Testing in Jmeter for Databases

Leave a Reply

Your email address will not be published. Required fields are marked *