What Is JDBC's Answer to Database Metadata? in JDBC

JDBC provides a low-level interface called DatabaseMetaData. This chapter explains how to dissect the DatabaseMetaData object in order to find out the table names, column names or types, stored procedures names and signatures, and other useful information. Before delving into the solution, let’s take a look at the relationships (see Figure) between important low-levelinterfaces and classes. There are several ways that you can create a Connection object. Once you have a valid Connection object, then you can create a DatabaseMetaData object.

According to JDK 1.5, the DatabaseMetaData allows you to obtain information about the database and has over one hundred methods.
To obtain a DatabaseMetaData object, use these general steps:

  1. Connect to a database by using an instance of the Connection object.
  2. To find out the names of the database schema, tables, and columns, get an instance of the DatabaseMetaData object from the Connection.
  3. Perform the actual query by issuing a SQL query string. Then use the Connection to create a Statement class to represent your query.
  4. The query returns a ResultSet. To find out the names of the column rows in that ResultSet, obtain an instance of the ResultSetMetaData class.

To get a DatabaseMetaData, use the following snippet:

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

JDBC Topics