Q)How to retrieve data from the database into a JDBC client? =>By submitting "SELECT SQL" statement we can retrieve data from the database. =>executeQuery() method of Statement object is used to submit SELECT statement to the DBMS. =>executeQuery() method takes "SELECT SQL statement" as a String argument. =>It returns ResultSet object. =>executeQuery() method throws SQLException if anything foes wrong. Q)Explain about ResultSet. =>Object oriented representation of database records received from the DBMS(database server) is nothing but ResultSet object. =>ResultSet object is logically divided into 3 partitions. 1)Zero Record Area 2)Records holding Area 3)No record Area =>When ResultSet is open, a logical pointer known as cursor points to ZERO record area of the ResultSet. =>When the cursor is pointing to ZERO record area or NO Record area, we should not try to read the data from the ResultSet.Otherwise, SQLException is raised =>java.sql.ResultSet has a method, "next()" to move the cursor. =>This method does two things. 1)moves the cursor in forward direction by one record area. 2)After moving the cursor, it returns true if record is present. It returns false if record is not there. =>ResultSet object has getter methods to read data from the ResultSet record. These methods take column number of the ResultSet record as argument and returns the value. Q)Write a Java program to retrieve all the accounts from the database and display their details. import java.sql.*; class ReadAccounts { public static void main(String[] args) throws SQLException { Connection connection=DriverManager.getConnection("jdbc:mysql://localhost:3306/hdfcdb","root","ashokit"); Statement statement=connection.createStatement(); ResultSet resultSet=statement.executeQuery("SELECT * FROM ACCOUNT"); System.out.println("ACCNO\tNAME\tBALANCE"); while(resultSet.next()) { System.out.println(resultSet.getInt(1)+"\t"+resultSet.getString(2)+"\t"+resultSet.getDouble(3)); } resultSet.close(); statement.close(); connection.close(); } }