How Do You Retrieve Metadata from RowSetMetaData? in JDBC

A JDBC application can get metadata information about the columns in a RowSet object (such as CachedRowSet or WebRowSet) by invoking ResultSetMetaData and RowSetMetaData methods on a RowSetMetaData object. The following code fragment, in which webRS is a WebRowSet object, illustrates the process. The first line creates a WebRowSet object. The second line creates a RowSetMetaData object with information about the columns in webRS. The method getMetaData(), inherited from the ResultSet interface, returns a ResultSetMetaData object, which is cast to a RowSetMetaData object before being assigned to the variable rsMD. The third line finds out how many columns rsMD has, and the fourth line gets the JDBC type of values stored in the second column of webRS.

According to the J2SE 5.0 documentation , the RowSetMetaData interface differs from the ResultSetMetaData interface in two ways:

  • It includes setter methods: A RowSet object uses these methods internally when it is populated with data from a different ResultSet object.
  • It contains fewer getter methods: Some ResultSetMetaData methods do not apply to a RowSet object. For example, methods retrieving whether a column value is writable or read only do not apply because all of a RowSet object’s columns will be writable or read only, depending on whether or not the rowset is updatable.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

JDBC Topics