JDBC ResultSet Example

Advertisement

In this This tutorial you will learn how to use java.sql.ResultSet interface in an application, and how update a database table using ResultSet.

JDBC ResultSet Example

JDBC ResultSet is an interface of java.sql package. It is a table of data
representing a database query result, which is obtained by executing the execute
method of statement. A ResultSet object points the cursor to the first row of
the data. Initially the cursor point before the fist row of the data. to move
the cursor next() method is called. If there is no any row present in the result
then it returns the false value.

The default ResultSet object is not updateable therefore the cursor
moves only forward from the first row to the last row only once. It is possible
to make ResultSet object that is updateable and acrollable. to make such type of
ResultSet object you need to write the following code.

The ResultSet object also provides a getter method that that gets the value
from the ResultSet object table. You need to specify only the Column name or
index no of the table. For example- resultSet.getString("ColumnName");,
resultSet.getInt("ColumnName");,