To make operations on the database we should know the data formats of the database. When using a ResultSet it is possible to access metadata for the data returned from the query. To obtain an object which encapsulates this metadata, use the method getMetaData () from the ResultSet class. This method returns an object of the ResultSetMetaData class and allows us to determine the number and type of columns.

Like ResultSetMetaData we can get metadata for databases. The DatabaseMetaData class is used for obtaining database metadata. Like ResultsetMetaData, DataBaseMetaData also contains several methods which describe the database. Here is an example which uses DatabaseMetaData to retrieve a list of tables from the database: