JAVA JDBC Programming Question:

How can you retrieve data from the ResultSet using JDBC?

Tweet Share WhatsApp

Answer:

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.

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

Second:
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 PDF Read All 19 JDBC Questions
Previous QuestionNext Question
How can you create JDBC statements?What are the different types of Statements in JDBC?