How Can You Create a Custom RowSetMetaData Object? JDBC

JDBC provides a basic class (javax.sql.rowset.RowSetMetaDataImpl) for implementing a custom RowSetMetaData object. This means that implementations almost have to be proprietary. The JDBC RowSet package is the most commonly available and offers the sun.jdbc.rowset. RowSetMetaDataImpl class.

After instantiation of RowSetMetaDataImpl, any of the RowSetMetaData setter methods may be used. The minimum needed for a RowSet to function is to set the column count(RowSetMetaData.setColumnCount()) for a row and the column type
(RowSetMetaData.setColumnType()) for each column in the row.

For example, the following code segment will populate two columns called id and name with three rows. After populating the CachedRowSet object, we commit the inserted records back to a designated data source.

The Solution

The following solution creates a custom-made RowSet metadata object. This provides a lot of freedom to RowSet developers to tailor their metadata according to the application’s data requirements.

The MySQL Database Before Running the Solution

The MySQL Database After Running the Solution


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

JDBC Topics