Updating a result set
Result Set rs = stmt.execute Query( "SELECT LAST_NAME, FIRST_NAME FROM EMPLOYEES"); int count = 0; while (rs.next()) println("Company XYZ has " count " employees."); rs = stmt.execute Query( "SELECT LAST_NAME, FIRST_NAME FROM EMPLOYEES"); while (rs.next()) methods provide the means for retrieving column values from the current row.
For maximum portability with forward only result sets, values should be retrieved from left to right, and column values should be read only once.
In this case, calling moves the cursor the specified number of rows from the current row, and it must be invoked only while the cursor is on the current row.
The following code fragment fixes the problems in the previous example.
With scrollable result sets, however, there are no such restrictions.
Either the column name or the column number can be used to designate the column from which to retrieve data.
In some cases, it is possible for an SQL query to return a result set that has more than one column with the same name.
If a column name is used as the parameter to a will return the value of the first matching column name.
A result set is also a table with rows and columns, but it contains only the column values from a database table that satisfy the conditions of a query.Because an application can iterate through a forward-only result set just once, the same query needs to be executed twice.In the iteration through the first rs, the number of rows is counted; in the iteration through the second rs, the data is retrieved.A relational database is made up of tables, with each table consisting of rows and columns.A row in a relational database table can be thought of as representing an instance of the entity that the table represents.