Ad Code

How we process the results of sql query.


How we process the results of sql query.

Process Results of the Query
 The ResultSet provides various getXXX methods that takes a column index or name and returns the data
 The ResultSet maintains the data in the form tables (rows & columns)
 First row has index 1, not 0.
 The next method of ResultSet returns true or false depending upon whether the next row is available (exist) or not and moves the cursor
 Always remember to call next() method at-least once
 To retrieve the data of the column of the current row you need to use the various getters provided by the ResultSet.
 For example, the following code snippet will iterate over the whole ResultSet and illustrates the usage of getters methods
while ( rs.next() ){ //by using column name String name = rs.getString(“columnName”); // or by using column index String name = rs.getString(1);}
Reactions

Post a Comment

0 Comments