Database Testing Using Selenium

Generally We don’t have to Test entire database of our application.To my knowledge, We use Selenium to test the Database whether data given in the front end(UI) is as same as the data present in the Database(Back End).

Note: We don’t do negative testing in database.

Here i am using MySql to test the database.
You need to Download Java.sql jar and configure database in your system. I’ll explain database configuration in Upcoming posts.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

import org.openqa.selenium.WebDriver;
import org.testng.annotations.Test;

public class testng_8
public WebDriver fd;
public void method_sql() throws Exception
Connection cn=DriverManager.getConnection(“jdbc:mysql:wombat”, “myLogin”, “myPassword”);
Statement st=cn.createStatement();
ResultSet rs= st.executeQuery(“select * from emp”);
try {
while (


catch (Exception e)


3 thoughts on “Database Testing Using Selenium

  1. Shabe Noor June 2, 2015 / 11:29 pm

    Very nice work.keep doing the good work.

    Liked by 1 person

  2. Savitha July 30, 2015 / 12:58 am

    Plz tell me how to configure sql with java to perform database testing


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s