All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.xmlmiddleware.xmldbms.maps.utils.MetadataInitializer

java.lang.Object
   |
   +----org.xmlmiddleware.xmldbms.maps.utils.MetadataInitializer

public class MetadataInitializer
extends Object
Initializes the metadata in an XMLDBMSMap object from a database.

Metadata must be set for any columns for which data is to be transferred. The result of not setting metadata is undefined. Metadata can be set in a number of ways: (1) from a map document, (2) from a database, (3) from a result set, or (4) directly on Column objects.

You can use the methods in this class to set metadata from a database or a result set. When initializing metadata from a database, the "required" argument specifies whether metadata must be found for all tables in the database. In most cases, you set this argument to true. You set it to false if you want to retrieve metadata for some tables from the database, then retrieve metadata for other tables from another source, such as a result set.

You can use XMLDBMSMap.checkMetadata() to determine if metadata has been set for all tables.

The methods in this class overwrite any existing metadata for tables for which they find metadata.

Version:
2.0
Author:
Ronald Bourret

Constructor Index

 o MetadataInitializer(XMLDBMSMap)
Construct a new MetadataInitializer.

Method Index

 o initializeMetadata(String, Connection, boolean)
Initialize database metadata from a single database.
 o initializeMetadata(String, String, String, String, ResultSet)
Initialize database metadata from a result set.
 o initializeMetadata(String[], Connection[], boolean)
Initialize database metadata from multiple databases.
 o initializeMetadata(Table, ResultSet)
Initialize database metadata from a result set.

Constructors

 o MetadataInitializer
 public MetadataInitializer(XMLDBMSMap map)
Construct a new MetadataInitializer.

Parameters:
map - The XMLDBMSMap to initialize.

Methods

 o initializeMetadata
 public void initializeMetadata(String databaseName,
                                Connection conn,
                                boolean required) throws XMLMiddlewareException
Initialize database metadata from a single database.

Parameters:
databaseName - The name of the database. If this is null, "Default" is used.
conn - A connection to the database.
required - Whether database metadata is required for all tables.
Throws: XMLMiddlewareException
Thrown if metadata is not found for a column or if required is true and metadata is not found for a table.
 o initializeMetadata
 public void initializeMetadata(String databaseNames[],
                                Connection conns[],
                                boolean required) throws XMLMiddlewareException
Initialize database metadata from multiple databases.

Parameters:
databaseNames - The names of the databases. If any name is null, "Default" is used.
conns - The connections to the databases.
required - Whether database metadata is required for all tables.
Throws: XMLMiddlewareException
Thrown if metadata is not found for a column or if required is true and metadata is not found for a table.
 o initializeMetadata
 public void initializeMetadata(String databaseName,
                                String catalogName,
                                String schemaName,
                                String tableName,
                                ResultSet rs) throws XMLMiddlewareException
Initialize database metadata from a result set.

This method initializes metadata only for the specified table. (This is the "table" that maps the result set.) This method does not affect metadata for other tables. Thus, it can be called for different tables, such as when multiple result sets are passed to DBMSToDOM.retrieveDocument.

This method is liberal with respect to metadata. That is, if any columns in the result set are not mapped, or if any columns in the specified table are not in the result set, they are ignored. This allows a single mapping to be used for multiple result sets based on the same table.

Parameters:
databaseName - The name of the database used to map the result set. If this is null, "Default" is used.
catalogName - The name of the catalog used to map the result set. May be null.
schemaName - The name of the schema used to map the result set. May be null.
tableName - The name of the table used to map the result set.
rs - The result set.
Throws: XMLMiddlewareException
Thrown if the table is not found or an error occurs retrieving the metadata.
 o initializeMetadata
 public void initializeMetadata(Table table,
                                ResultSet rs) throws XMLMiddlewareException
Initialize database metadata from a result set.

This method initializes metadata only for the specified table. (This is the "table" that maps the result set.) This method does not affect metadata for other tables. Thus, it can be called for different tables, such as when multiple result sets are passed to DBMSToDOM.retrieveDocument.

This method is liberal with respect to metadata. That is, if any columns in the result set are not mapped, or if any columns in the specified table are not in the result set, they are ignored. This allows a single mapping to be used for multiple result sets based on the same table.

Parameters:
table - The Table used to map the result set.
rs - The result set.
Throws: XMLMiddlewareException
Thrown if the table is not found or an error occurs retrieving the metadata.

All Packages  Class Hierarchy  This Package  Previous  Next  Index