Accessing Table Metadata

Information about the Host Integrator ‘database’ (that is, model that you are using) is available in two forms: ResultSet metadata and Database metadata.

ResultSet Metadata

After performing a SQL SELECT statement, you can retrieve metadata from the returned ResultSet object. By calling the getMetaData method of ResultSet to obtain a ResultSetMetaData object for that ResultSet, you can then query several items of metadata. Some of the most important items for Host Integrator are:

ResultSet MetaData method name Description
getColumnCount Returns the number of columns in a row of the ResultSet.
getColumnName Gets the name of a column in the ResultSet.
getColumnType Gets the data type of a column in the ResultSet (from java.sql.Types).
getTableName Gets the name of the Host Integrator table being used with this connection.

Database Metadata

For information about the database being used in the current connection, use the DatabaseMetaData object. For Host Integrator, the term 'database' refers to the model being used for the session. You can obtain the DatabaseMetaData object for a current connection by executing the getMetaData method on the current JDBC connection object. for example:

	DatabaseMetaData DBMetaData = myConnection.getMetaData();

With the DatabaseMetaData object, you can find out many things about the Host Integrator model being used. The most important of these are:

Database MetaData method name Description
getColumns Returns information about table columns available for a table in the Host Integrator model.
getConnection Gets the connection object that produced the DatabaseMetaData object.
getPrimaryKeys Returns information about the primary key columns for a table in the Host Integrator model (as designated by the model designer).
getProcedures Returns information about stored (table) procedures available in the Host Integrator model.
getProcedureColumns Returns information about the input, output, and results associated with stored (table) procedures available in the Host Integrator model.
getTables Returns information about tables available in the Host Integrator model.

 

Related Topics
Bullet Connecting to Host Integrator Servers
Bullet JDBC Connector Introduction
Bullet SQL Overview