4.2.5.2 Using the DatabaseMetaData Interface
Compared with other metadata interfaces, the DatabaseMetaData is the largest, with over 150 methods. This interface is mainly used by developers who are building database applications that need to be fully RDBMS independent, which means that the developers do not need to know any-thing about the database or have prior knowledge about the database they are using. In this way, the users can discover and retrieve structures and properties of the RDBMS dynamically as the application runs.
To create a DatabaseMetaData object, one needs to call the getMetaData() method defined in the Connection interface.
Relatively speaking, the ResultSetMetaData interface allows you to discover the structure of Tables and properties of columns, but the DatabaseMetaData interface enables you to dynami-cally determine properties of the RDBMS. Table 4.11 shows the 16 most popular and important methods widely implemented by the DatabaseMetaData interface.
These 16 methods can be divided into seven groups based on their functionalities:
1) Catalog Identification Methods
2) Database Identification Methods
3) Driver Identification Methods
4) Stored Procedure–Related Methods
5) Schema Identification Methods
6) Table Identification Methods
7) Database-Related Parameter Methods
To get the name and version of the current database being used, the getDatabaseProd-uct-Name() and getDatabaseProductVersion() methods can be used. Similarly, to get thename and revision number of the JDBC driver being used, the getDriverName() and getDriv-erVersion() methods can be executed.

In fact, the DatabaseMetaData interface provides methods that allow you to dynamically dis-cover properties of a database as the project runs. Many methods in DatabaseMetaData return information in the ResultSet component, and one can get those pieces of information from the ResultSet object by calling related methods such as getString(), getInt() and getXXX(). An exception would be thrown if the queried item is not available in the MetaData interface.
Overall, the DatabaseMetaData interface provides an easy and convenient way to allow users to identify and retrieve important structure and property information about the database dynamically.