Creating a DatabaseMetadata Object
A DatabaseMetaData object is created with the Connection method
getMetaData. Once created, it can be used to dynamically discover information
about the underlying data source. CODE EXAMPLE 7-1 creates a DatabaseMetadata
object and uses it to determine the maximum number of characters allowed for a
table name.
// con is a Connection object
DatabaseMetaData dbmd = con.getMetadata();
int maxLen = dbmd.getMaxTableNameLength();
CODE EXAMPLE 7-1 Creating and using a DatabaseMetadata object
SQL Objects and Their Attributes
Some DatabaseMetaData methods provide information about the SQL objects that
populate a given data source. This group also includes methods to determine the
attributes of those objects. Methods in this group return ResultSet objects in
which each row describes a particular object. For example, the method getUDTs
returns a ResultSet object in which there is a row for each UDT that has been
defined in the data source. Examples of this category are:
■ getSchemas
■ getCatalogs
■ getTables
■ getPrimaryKeys
■ getProcedures
■ getProcedureColumns
■ getUDTs
■ getFunctions
■ getFunctionColumns
// -- more information refer to JSR221 - JDBC™ 4.0 Specification
http://exampledepot.com/taxonomy/term/213 这个网页有下面一些例子
Getting the Maximum Table Name Length in a Database
Getting the Name of a JDBC Type
Listing All Non-SQL92 Keywords Used by a Database
Listing Available SQL Types Used by a Database
Listing the Numeric Functions Supported by a Database
Listing the String Functions Supported by a Database
Listing the System Functions Supported by a Database
Listing the Time and Date Functions Supported by a Database