How Do You Create a RowSetMetaData Object? JDBC

To create (materialize) a RowSetMetaData object, you need to create a RowSet object (or descendent objects such as a WebRowSet or JdbcRowSet object) and then invoke the getMetaData() method on that object. The following code snippet shows how to create a RowSetMetaData object:

You need to cast RowSet.getMetaData() to the RowSetMetaData object, because RowSet does not have a method that returns a RowSetMetaData object (note that getMetaData() is inherited from the ResultSetMetaData interface). Next, we set up sample databases for MySQL and ODBC (using Microsoft Access on Windows XP). Then we apply our solution to these databases.

MySQL Database Setup

ODBC Database Setup

Using the ODBC Data Source Administrator, create a data source. Call it odbc and create a table called ztest (similar to the MySQL table in the previous section).

The Solution

Here is a simple class to create a RowSetMetaData object. Note the following line of code:

Running the Solution for a MySQL Database

Running the Solution for an ODBC Database

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

JDBC Topics