Saturday, 1 September 2012

How can we retrieve data from the ResultSet?


• JDBC returns back the results in a ResultSet object. 

• So we have to declare an instance of the class ResultSet to keep the results.

• The following code declares the ResultSet object rs.

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

• The method getString calls ResultSet object rs, So getString() retrieves the value stored in the column NAME in the row Ssrs.

No comments:

Post a Comment