ResultSet MetaData

ResultSetMetadata can be used to discover information about the columns that comprise the rows of a query result. The ResultSetMetadata for a SELECT statement can be retrieved by invoking the getResultSetMetadata() method of the Statement object.

The ResultSetMetadata information includes the number of columns in a result row, each column's data type, the label given to the column, the name of the column from the table, and the name of the table for each column.

If a label was not specified for a column, the name of the column from the table is used as the label. If a label was not specified for a column and the column is not from a table, but is an expression that is calculated as part of the result, the entire expression string is used as the label. It is always safest to access a column of a ResultSet by its label as a ResultSet column always has a label but might not necessarily have a name from a table.

Related concepts