12.2. Metadata
The JDBC specification features a ResultSetMetaData object that can be used to get metadata regarding a result set.
The following code example from the API creates a result set and then creates a ResultSetMetaData object. It uses the MetaData object to determine how many columns are in the result set and whether the first column can be used in a WHERE clause.
ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM TABLE2"); ResultSetMetaData rsmd = rs.getMetaData(); int numberOfColumns = rsmd.getColumnCount(); boolean b = rsmd.isSearchable(1);
To find out more about what methods are available to a ResultSetMetaData object, I encourage you to visit the java.sql package in the API and work with this class further.
Get Java™ for ColdFusion® Developers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.