ResultSetMetaData
offers methods to retrieve details about the columns of a ResultSet
object. These details can include column type, column name, column label, and many other characteristics. By using this metadata, developers can dynamically interact with result sets, even when the specific structure or details of the returned data might not be known in advance.
getColumnCount
Provides the total number of columns in the ResultSet
object.
Signature:
int getColumnCount() throws SQLException
Returns:
Return Type | Description |
---|---|
int | The number of columns in the ResultSet . |
isAutoIncrement
Indicates whether a column is automatically incremented.
Signature:
boolean isAutoIncrement( int columnIndex ) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
columnIndex | int | The index of the column to check (1-based). |
Returns:
Return Type | Description |
---|---|
boolean | true if the column is automatically incremented; false otherwise. |
isCaseSensitive
Determines if a column’s case matters for the database operations.
Signature:
boolean isCaseSensitive( int columnIndex ) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
columnIndex | int | The index of the column to check (1-based). |
Returns:
Return Type | Description |
---|---|
boolean | true if the column is case sensitive; false otherwise. |
isSearchable
Indicates if a column can be used in a WHERE clause.
Signature:
boolean isSearchable( int columnIndex ) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
columnIndex | int | The index of the column to check (1-based). |
Returns:
Return Type | Description |
---|---|
boolean | true if the column can be used in a WHERE clause; false otherwise. |
isCurrency
Determines if a column contains a currency value.
Signature:
boolean isCurrency( int columnIndex ) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
columnIndex | int | The index of the column to check (1-based). |
Returns:
Return Type | Description |
---|---|
boolean | true if the column contains currency; false otherwise. |
isNullable
Provides information about the nullability of a column.
Signature:
int isNullable( int columnIndex ) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
columnIndex | int | The index of the column to check (1-based). |
Returns:
Return Type | Description |
---|---|
int | One of ResultSetMetaData.columnNoNulls , ResultSetMetaData.columnNullable , or ResultSetMetaData.columnNullableUnknown indicating the nullability status. |
isSigned
Indicates whether the values in the designated column are signed numbers.
Signature:
boolean isSigned( int columnIndex ) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
columnIndex | int | The index of the column to check (1-based). |
Returns:
Return Type | Description |
---|---|
boolean | true if the values in the column are signed numbers; false otherwise. |
getColumnDisplaySize
Provides the suggested display size for the designated column.
Signature:
int getColumnDisplaySize( int columnIndex ) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
columnIndex | int | The index of the column (1-based). |
Returns:
Return Type | Description |
---|---|
int | The suggested column display size in characters. |
getColumnLabel
Fetches the suggested column label for use in printouts and displays.
Signature:
String getColumnLabel(int columnIndex) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
columnIndex | int | The index of the column (1-based). |
Returns:
Return Type | Description |
---|---|
String | The suggested column label. |
getColumnName
Provides the name of the designated column.
Signature:
String getColumnName( int columnIndex ) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
columnIndex | int | The index of the column (1-based). |
Returns:
Return Type | Description |
---|---|
String | The name of the designated column. |
getSchemaName
Fetches the name of the schema of the designated column’s table.
Signature:
String getSchemaName( int columnIndex ) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
columnIndex | int | The index of the column (1-based). |
Returns:
Return Type | Description |
---|---|
String | The schema name or an empty string if not applicable. |
getPrecision
Provides the specified column’s number of decimal digits.
Signature:
int getPrecision( int columnIndex ) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
columnIndex | int | The index of the column (1-based). |
Returns:
Return Type | Description |
---|---|
int | The precision of the column. |
getScale
Fetches the designated column’s number of digits to the right of the decimal point.
Signature:
int getScale( int columnIndex ) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
columnIndex | int | The index of the column (1-based). |
Returns:
Return Type | Description |
---|---|
int | The scale of the column. |
getTableName
Returns the name of the table associated with the designated column.
Signature:
String getTableName( int columnIndex ) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
columnIndex | int | The index of the column (1-based). |
Returns:
Return Type | Description |
---|---|
String | The name of the table or an empty string if not applicable. |
getCatalogName
Provides the name of the catalog for the table of the designated column.
Signature:
String getCatalogName( int columnIndex ) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
columnIndex | int | The index of the column (1-based). |
Returns:
Return Type | Description |
---|---|
String | The catalog name or an empty string if not applicable. |
getColumnType
Provides the SQL type from java.sql.Types
of the designated column.
Signature:
int getColumnType(int columnIndex) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
columnIndex | int | The index of the column (1-based). |
Returns:
Return Type | Description |
---|---|
int | SQL type from java.sql.Types of the designated column. |
getColumnTypeName
Fetches the database-specific type name of the designated column.
Signature:
String getColumnTypeName( int columnIndex ) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
columnIndex | int | The index of the column (1-based). |
Returns:
Return Type | Description |
---|---|
String | The database-specific type name of the column. |
isReadOnly
Indicates whether the designated column is guaranteed to not be writable.
Signature:
boolean isReadOnly( int columnIndex ) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
columnIndex | int | The index of the column (1-based). |
Returns:
Return Type | Description |
---|---|
boolean | true if the column is read-only; false otherwise. |
isWritable
Indicates whether it is possible for a write operation on the designated column.
Signature:
boolean isWritable( int columnIndex ) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
columnIndex | int | The index of the column (1-based). |
Returns:
Return Type | Description |
---|---|
boolean | true if the column is writable; false otherwise. |
isDefinitelyWritable
Indicates whether a write on the designated column will definitely succeed.
Signature:
boolean isDefinitelyWritable(int columnIndex) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
columnIndex | int | The index of the column (1-based). |
Returns:
Return Type | Description |
---|---|
boolean | true if the column is definitely writable; false otherwise. |
getColumnClassName
Provides the fully qualified name of the Java class whose instances are manufactured if the method ResultSet.getObject
is called to retrieve a value from the column.
Signature:
String getColumnClassName( int columnIndex ) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
columnIndex | int | The index of the column (1-based). |
Returns:
Return Type | Description |
---|---|
String | The fully qualified name of the Java class. |
unwrap
Returns an object that implements the given interface to allow access to non-standard methods or for the use of proxy chains.
Signature:
<T> T unwrap( Class<T> aClass ) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
aClass | Class<T> |
The type of the object to be returned. |
Returns:
Return Type | Description |
---|---|
T | An object that implements the interface. |
isWrapperFor
Determines if this object is an instance of a class that implements the given interface.
Signature:
boolean isWrapperFor( Class<?> aClass ) throws SQLException
Parameters:
Parameter Name | Type | Description |
---|---|---|
aClass | Class<?> |
The interface to check against. |
Returns:
Return Type | Description |
---|---|
boolean | true if this object implements the interface; false otherwise. |