Database Connection in Selenium


  • Below is the source code to connect your MySQL database with Selenium :
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection) DriverManager.getConnection ("jdbc:mysql://localhost:3306/demo","username","password");
Statement stmt = (Statement) con.createStatement();
// Below statement we use for executing sql queries.
stmt.executeQuery("Select * from dbtable");

In order to connect, you will need to add one jar file which you can download by clicking here

  • To connect Oracle database with Selenium, write below code:
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con =
DriverManager.getConnection("jdbc:oracle:thin:@localhost: 
1521:orcl","username","password");
Statement stmt = con.createStatement();
stmt.executeQuery("Select * from dbtable");

In order to connect, you will need to add one jar file which you can download by clicking here

Selenium Webdriver Architecture


This diagram is just to show how Selenium Webdriver works. If anyone asks for Selenium Webdriver architecture then just need to design the below diagram and explain it. I share this as it is one of the most frequently asked Selenium Question

Selenium Architecture
Selenium Webdriver Architecture

Selenium Remote Control Architecture


This diagram is just to show how Selenium Remote Control works. If anyone asks for Selenium RC architecture then just need to design the below diagram and explain it. I share this as it is one of the most frequently asked Selenium Question


Selenium RC Architecture
Selenium Remote Control Architecture