SQLResultSetMetaData class

The SQLResultSetMetaData class returns information about the columns of an SQLResultSetRowData object. You can either provide the result set when you set the constructor's parameters or use the get and set methods to access the result set meta data.

The following example shows you how to create an SQLResultSetMetaData object:

// Create an SQLResultSetMetaData object from the result set's metadata.
SQLResultSetRowData rowdata = new SQLResultSetRowData(resultSet);
SQLResultSetMetaData sqlMetadata  = rowdata.getMetaData();

// Display the column precision for non-text columns.
String name = null;
int numberOfColumns = sqlMetadata.getColumnCount();
for (int column=0; column < numberOfColumns; column++)
{   
   name = sqlMetadata.getColumnName(column);
   if (sqlMetadata.isTextData(column))
   {
      System.out.println("Column: " + name + " contains text data."); 
   }
   else
   {
      System.out.println("Column: " + name + " has a precision of " + sqlMetadata.getPrecision(column));
   }
}