Database Test Plan with JMeter

Let us see how we can test the database in Jmeter using JDBC Request Sampler.
In this tutorial we will use oracle jdbc driver.
Required jar E.g. “ojdbc6.jar” is placed in <JMETER_Path>/lib.
Prepare a Test Plan as shown below:
Testplan

Here we have added:
  1. User Defined Variables – Defined the required parameters for Database Connection
  2. JDBC Connection Configuration
  3. Thread Group
  4. JDBC Request under Thread Group
  5. BeanShell Sampler – To display the output of the JDBC Request.
  6. View Results Tree – To View the Results
JDBC Request Sampler is used to send an JDBC Request to database. But before using this we need to setup the required JDBC connection and it is done via JDBC Connection Configuration element.
Under JDBC Connection Configuration we have the below defined values:
JDBC Connection
We defined the Variable Name as “JDBC_Pool”. The values required for Database Connection are defined in User Defined Variables and are used here.
E.g:
jdbc_url = jdbc:oracle:thin:@DB_Server:port:DB_Instance
jdbc_driver = oracle.jdbc.OracleDriver
jdbc_user = User to connect to DB. E.g. sa
jdbc_pass = Password for the above user
Under JDBC request we have the below values:
JDBC Request
The Variable Name should be same as that of Variable Name of JDBC Connection Configuration.
We have different type of Query types as below:
SQL Query
In our example we selected “Select Statement” as Query type.
In the Query section, write the exact SQL query for execution
Under Variable names : Define a variable e.g. sql_var.
Note: This field can contain a comma-separated list of variable names to hold values returned by Select statements, Prepared Select Statements or CallableStatement.
Overall

Under BeanShell Sampler we wrote below line to display the records in the Log Viewer.
Beanshell
Run the Test and view the results have the below output:
View Results

If we view the result, it took a significant time ~ 6mins to process the JDBC Request.

Comments

Post a Comment

Popular posts from this blog

Steps to Analyze AWR Report in Oracle

Vmstat Output explained

Verifications and Error Handling in LoadRunner *Web_reg_find and Web_reg_save_param*