ResultSet interface in detail:
- ResultSet object returned by executeQuery() method or execute() method.
- ResultSet Object holds the records information collect through select query.
- The object of ResultSet maintains a cursor pointing to a row of a table.
- Initially, cursor points to before the first row.
Method Name | Description |
public boolean next(): | It is used to move the cursor to the one row next from the current position. |
public int getInt(int columnIndex): | It is used to return the data of specified column index of the current row as int. |
public int getInt(String columnName): | It is used to return the data of specified column name of the current row as int. |
public String getString(int columnIndex): | It is used to return the data of specified column index of the current row as String. |
public String getString(String columnName): | It is used to return the data of specified column name of the current row as String. |
Java ResultSetMetaData Interface:
- The metadata means data about data.
- If you have to get metadata of a table like total number of column, column name, column type etc.
- Methods of ResultSetMetaData interface as follows:
Method | Description |
public int getColumnCount()throws SQLException | It returns the total number of columns in the ResultSet object. |
public String getColumnName(int index)throws SQLException | It returns the column name of the specified column index. |
public String getColumnTypeName(int index)throws SQLException | It returns the column type name for the specified index. |
public String getTableName(int index)throws SQLException | It returns the table name for the specified column index. |