Thursday 4 February 2016

DB connection from selenium

  • In order to test Database using Selenium you need to
    1. Make a connection to the Database
    2. Send Queries to the Database
    3. Process the results
  • The Syntax to connect to Database is
    • DriverManager.getConnection(URL, "userid", "password" )
  • You will also need the Statement Object to send queries
    • Statement stmt = con.createStatement();
  • To send the query to database use execute query and store the results in the ResultSet object
    • ResultSet rs = stmt.executeQuery(select * from employee;);
  • Java provides lots of built-in methods to process the SQL Output using the ResultSet Object

No comments:

Post a Comment