org.objectweb.cjdbc.controller.backend
Class DatabaseBackendMetaData

java.lang.Object
  extended byorg.objectweb.cjdbc.controller.backend.DatabaseBackendMetaData

public class DatabaseBackendMetaData
extends java.lang.Object

A DatabaseBackendMetaData is used to retrieve the database schema of a real database backend that will have to be bound to a virtual C-JDBC database.

Version:
1.0
Author:
Julie Marguerite, Emmanuel Cecchet, Sara Bouchenak, Mathieu Peltier

Field Summary
private  AbstractConnectionManager connectionManager
          Connection manager to get a connection from.
private  DatabaseSchema databaseSchema
          Schema of the database backend.
private  Trace logger
          Logger instance.
 
Constructor Summary
DatabaseBackendMetaData(AbstractConnectionManager connectionManager, Trace logger)
          Creates a new DatabaseBackendMetaData instance.
 
Method Summary
private  void createDatabaseSchema()
          Gets the list of tables of a database and add them to the database schema.
private  void getColumns(java.sql.DatabaseMetaData metaData, DatabaseTable table)
          Gets the list of columns of a given database table.
 DatabaseSchema getDatabaseSchema()
          Returns the database schema.
private  void getPrimaryKeys(java.sql.DatabaseMetaData metaData, DatabaseTable table)
          Gets the primary keys of a given database table.
private  void getProcedures(java.sql.DatabaseMetaData metaData, DatabaseSchema schema)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connectionManager

private AbstractConnectionManager connectionManager
Connection manager to get a connection from.


logger

private Trace logger
Logger instance.


databaseSchema

private DatabaseSchema databaseSchema
Schema of the database backend.

Constructor Detail

DatabaseBackendMetaData

public DatabaseBackendMetaData(AbstractConnectionManager connectionManager,
                               Trace logger)
Creates a new DatabaseBackendMetaData instance. This class takes care of initializing the connection manager if needed but the driver must have been previously loaded else the connection manager's initialization will fail.

Parameters:
connectionManager - the connection manager to gather the schema from
logger - the logger (usually the backend logger) to use
Method Detail

createDatabaseSchema

private void createDatabaseSchema()
                           throws java.sql.SQLException
Gets the list of tables of a database and add them to the database schema. The caller must ensure that the parameters are not null.

Throws:
java.sql.SQLException - if an error occurs

getProcedures

private void getProcedures(java.sql.DatabaseMetaData metaData,
                           DatabaseSchema schema)
                    throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
DatabaseMetaData.getProcedures(java.lang.String, java.lang.String, java.lang.String), DatabaseMetaData.getProcedureColumns(java.lang.String, java.lang.String, java.lang.String, java.lang.String)

getColumns

private void getColumns(java.sql.DatabaseMetaData metaData,
                        DatabaseTable table)
                 throws java.sql.SQLException
Gets the list of columns of a given database table. The caller must ensure that the parameters are not null.

Parameters:
metaData - the database meta data
table - the database table
Throws:
java.sql.SQLException - if an error occurs

getPrimaryKeys

private void getPrimaryKeys(java.sql.DatabaseMetaData metaData,
                            DatabaseTable table)
                     throws java.sql.SQLException
Gets the primary keys of a given database table. The caller must ensure that the parameters are not null.

Parameters:
metaData - the database meta data
table - the database table
Throws:
java.sql.SQLException - if an error occurs

getDatabaseSchema

public DatabaseSchema getDatabaseSchema()
                                 throws java.sql.SQLException
Returns the database schema. Returns null If an error has occured during the schema generation.

If the schema has not been previously computed, createDatabaseSchema() is called.

Returns:
a DatabaseSchema value
Throws:
java.sql.SQLException - if a problem occurs when creating the database schema
See Also:
createDatabaseSchema()


Copyright © 2002, 2003 - ObjectWeb Consortium - All Rights Reserved.