JAVA JDBC Programming Question:
Download Questions PDF

How can you retrieve data from the ResultSet using JDBC?


First JDBC returns results in a ResultSet object, so we need to declare an instance of the class ResultSet to hold our results. The following code demonstrates declaring the ResultSet object rs.

ResultSet rs = stmt.executeQuery(”SELECT COF_NAME, PRICE FROM COFFEES”);

String s = rs.getString(”COF_NAME”);

The method getString is invoked on the ResultSet object rs , so getString will retrieve (get) the value stored in the column COF_NAME in the current row of rs

Download JDBC Interview Questions And Answers PDF

Previous QuestionNext Question
How can you create JDBC statements?What are the different types of Statements in JDBC?