title: Get row of database(phpmyadmin) datatable using selenium webdriver
body: <p>I am new to selenium driver . How to get data of row from database table. I tried this code where my database name is "demodatabase" , table name is "state" and row id is 2</p>
  
  <pre><code>package com.db;
  
  import java.sql.Array;
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.sql.Statement;
  
  
  
  public class DbConnection {
  
      public static void main(String[] args) throws ClassNotFoundException, SQLException{
  
          /*------connection url----*/
          String dbUrl= "jdbc:mysql://localhost/demodatabase";
  
          /*------dbUsername----*/
          String dbUsername= "root";
  
          /*------dbPassword----*/
          String dbPassword= "";
  
          /*------db query---*/
          String query= "select * from states where id=2";
  
          /*-----load Mysql jdbc driver------*/
          Class.forName("com.mysql.jdbc.Driver");
  
  
          /*----Get connection to DB*/
          Connection con = DriverManager.getConnection(dbUrl, dbUsername, dbPassword);
  
          //create statement object
          Statement stmt = con.createStatement();
  
          //send sql query to database
          ResultSet rs= stmt.executeQuery(query);
  
  
          // while loop to get ResultSet all rows data
          while(rs.next()){
              String state =rs.getString("2");
              System.out.println(state);
          }
  
          //Close db connection
  
          con.close();
      }
  
  }
  </code></pre>
  
  <p><strong>Database table Screenshot</strong></p>
  
  <p><a href="http://i.stack.imgur.com/dcaGc.png" rel="nofollow">http://i.stack.imgur.com/dcaGc.png</a></p>
  
  <p>Using above code and database screenshoot .I am getting data of id=2 and column 2  i.e Jharkhand only but I want all data of row 2</p>