Viewing
a Result Set:
The ResultSet interface contains dozens of methods for
getting the data of the current row.
There is a get method for each of the possible data
types, and each get method has two versions:
·
One that takes in a column name.
·
One that takes in a column index.
For example, if the column you are interested in
viewing contains an int, you need to use one of the getInt() methods of
ResultSet:
public int
getInt(String columnName) throws SQLException
Methods & Description: Returns the int in the current row in the column named columnName |
|
public int
getInt(int columnIndex) throws SQLException
Methods & Description Returns the int in the current row in the specified column index. The column index starts at 1, meaning the first column of a row is 1, the second column of a row is 2, and so on. |
Similarly there are get methods in the ResultSet
interface for each of the eight Java primitive types, as well as common types
such as java.lang.String, java.lang.Object, and java.net.URL
There are also methods for getting SQL data types
java.sql.Date, java.sql.Time, java.sql.TimeStamp, java.sql.Clob, and
java.sql.Blob. Check the documentation for more information about using these
SQL data types.
Tags:
Advanced Java