Home | Previous Page | Next Page   Performing Database Operations >

Accessing Database Metadata

To access information about an Informix database, use the JDBC API DatabaseMetaData interface.

IBM Informix JDBC Driver implements all the JDBC 3.0 specifications for DatabaseMetaData methods.

The following new methods in DatabaseMetaData have been added in IBM Informix JDBC Driver 2.21.JC5 and later for JDBC 3.0 compliance:

Starting with Dynamic Server 10.0 and IBM Informix JDBC Driver 3.0, which is fully JDBC 3.0 specification compliant, new methods have been implemented to retrieve server-generated keys. Retrieving autogenerated keys involves the following actions:

  1. The JDBC application programmer provides an SQL statement to be executed.
  2. The server executes the SQL statement and an indication that autogenerated keys can be retrieved is returned.
  3. Before the server executes the SQL statement, columnNames or columnIndexes (if provided) are validated. An SQLException will be thrown if they are invalid.
  4. If requested, the JDBC driver and server returns a resultSet object. If no keys were generated, the resultSet is empty, containing no rows or columns.
  5. The user can request metadata for the resultSet object, and the JDBC driver and server will return a resultSetMetaData Object.

For more information on retrieving autogenerated keys, see the JDBC 3.0 Specification, Section 13.6, "Retrieving Auto Generated Keys."

IBM Informix JDBC Driver uses the sysmaster database to get database metadata. If you want to use the DatabaseMetaData interface in your Java program, the sysmaster database must exist in the Informix database server to which your Java program is connected. For example, IBM Informix SE does not have a sysmaster database, therefore you cannot use the DatabaseMetaData interface with it.

IBM Informix JDBC Driver interprets the JDBC API term schemas to mean the names of Informix users who own tables. The DatabaseMetaData.getSchemas() method returns all the users found in the owner column of the systables system catalog.

Similarly, IBM Informix JDBC Driver interprets the JDBC API term catalogs to mean the names of Informix databases. The DatabaseMetaData.getCatalogs() method returns the names of all the databases that currently exist in the Informix database server to which your Java program is connected.

The example DBMetaData.java shows how to use the DatabaseMetaData and ResultSetMetaData interfaces to gather information about a new procedure. Refer to Appendix A. Sample Code Files for more information about this example.

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]