Java Reference
In-Depth Information
In addition to obtaining the data stored in the database, it is frequently ver useful to be
able to obtain data about the database and its contents. This capability is supported
by the MetaData objects discussed in the next section .
MetaData
MetaData is information about the database or its contents made available by the
JDBC API.
These are the main types of MetaData accessible from JDBC:
 
DatabaseMetaData
 
ResultSetMetaData
 
ParameterMetaData
DatabaseMetaData
The DatabaseMetaData interface provides information about the underlying database
as a whole. The interface defines over 150 different methods providing the following
types of information about the database:
 
General information about the data source
 
Data-source limits
 
Levels of transaction support
 
Feature support
 
Information about the SQL objects that the source contains
Many of the DatabaseMetaData methods return information in ResultSets, allowing
you to use ResultSet methods such as getString and getInt to retrieve this information.
If a given form of MetaData is not available, these methods should throw a
SQLException.
Some of the DatabaseMetaData methods take arguments that are String patterns
conforming to the normal wild-card rules for SQL Strings. For pattern String
arguments, "%" means match any substring of zero or more characters, and "_"
means match any one character. If a search pattern argument is set to null, that
argument's criteria will be ignored in the search.
If a driver does not support a MetaData method, a SQLException will normally be
thrown. In the case of methods that return a ResultSet, either a ResultSet (which may
be empty) is returned or a SQLException is thrown.
A DatabaseMetaData object is created using the Connection.getMetaData() method.
It can then be used to get information about the database, as in the following example,
which gets the names of the tables in the database:
Search WWH ::




Custom Search