Package org.apache.torque

## Class Database

- java.lang.Object
- - org.apache.torque.Database

-     public class Database
      extends Object

  Bundles all information about a database. This includes the database adapter, the database Map and the Data Source Factory.

- - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addIdGenerator​(IDMethod type, IdGenerator idGen)` | Adds an IdGenerator to the database.
    `boolean` | `createAndRegisterIdBroker()` | Creates the IDBroker for this Database and registers it with Torque.
    `Adapter` | `getAdapter()` | Returns the adapter to this database.
    `DatabaseMap` | `getDatabaseMap()` | Returns the database map for this database.
    `DataSourceFactory` | `getDataSourceFactory()` | Returns the DataSourceFactory for this database.
    `IDBroker` | `getIdBroker()` | Get the IDBroker for this database.
    `IdGenerator` | `getIdGenerator​(IDMethod type)` | Returns the IdGenerator of the given type for this Database.
    `TableMap` | `getIdTable()` | Get the ID table for this database.
    `String` | `getName()` | Rturns the name of the database.
    `String` | `getSchema()` | Returns the database schema for this Database.
    `void` | `setAdapter​(Adapter anAdapter)` | Sets the adapter for this database.
    `void` | `setDataSourceFactory​(DataSourceFactory aDataSourceFactory)` | Sets the DataSourceFactory for this database.
    `void` | `setIdTable​(String tableName)` | Set the ID table for this database.
    `void` | `setIdTable​(TableMap idTable)` | Set the ID table for this database.
    `void` | `setSchema​(String schema)` | Sets the schema for this database.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getName

          public String getName()

      Rturns the name of the database.
      Returns:
        the name of the database, not null.

    - #### getAdapter

          public Adapter getAdapter()

      Returns the adapter to this database.
      Returns:
        the adapter to this database, or null if no adapter is set.

    - #### setAdapter

          public void setAdapter​(Adapter anAdapter)

      Sets the adapter for this database.
      Parameters:
        `anAdapter` - The adapter for this database, or null to remove the current adapter from this database.

    - #### getDatabaseMap

          public DatabaseMap getDatabaseMap()

      Returns the database map for this database.
      Returns:
        the DatabaseMap for this database, or null if no DatabaseMap exists for this database.

    - #### getDataSourceFactory

          public DataSourceFactory getDataSourceFactory()

      Returns the DataSourceFactory for this database. The DataSourceFactory is responsible to create connections to this database.
      Returns:
        the DataSourceFactory for this database, or null if no DataSourceFactory exists for this database.

    - #### setDataSourceFactory

          public void setDataSourceFactory​(DataSourceFactory aDataSourceFactory)

      Sets the DataSourceFactory for this database. The DataSourceFactory is responsible to create connections to this database.
      Parameters:
        `aDataSourceFactory` - The new DataSorceFactory for this database, or null to remove the current DataSourceFactory.

    - #### getIdTable

          public TableMap getIdTable()

      Get the ID table for this database.
      Returns:
        A TableMap, or null if not yet initialized or no id table exists for this database.

    - #### setIdTable

          public void setIdTable​(TableMap idTable)

      Set the ID table for this database.
      Parameters:
        `idTable` - The TableMap representation for the ID table.

    - #### setIdTable

          public void setIdTable​(String tableName)

      Set the ID table for this database.
      Parameters:
        `tableName` - The name for the ID table.

    - #### getIdBroker

          public IDBroker getIdBroker()

      Get the IDBroker for this database.
      Returns:
        The IDBroker for this database, or null if no IdBroker has been started for this database.

    - #### createAndRegisterIdBroker

          public boolean createAndRegisterIdBroker()

      Creates the IDBroker for this Database and registers it with Torque. so it is either started instantly if Torque is already initialized or it is started when Torque is initialized. The information about the IdTable is stored in the databaseMap. If an IDBroker already exists for this Database, the method does nothing.
      Returns:
        true if a new IDBroker was created, false otherwise.

    - #### getIdGenerator

          public IdGenerator getIdGenerator​(IDMethod type)

      Returns the IdGenerator of the given type for this Database.
      Parameters:
        `type` - The type (i.e.name) of the IdGenerator.
      Returns:
        The IdGenerator of the requested type, or null if no IdGenerator exists for the requested type.

    - #### addIdGenerator

          public void addIdGenerator​(IDMethod type,
                                     IdGenerator idGen)

      Adds an IdGenerator to the database.
      Parameters:
        `type` - The type of the IdGenerator.
        `idGen` - The new IdGenerator for the type, or null to remove the IdGenerator of the given type.

    - #### getSchema

          public String getSchema()

      Returns the database schema for this Database.
      Returns:
        the database schema for this database, or null if no schema has been set.

    - #### setSchema

          public void setSchema​(String schema)

      Sets the schema for this database.
      Parameters:
        `schema` - the name of the database schema to set, or null to remove the current schema.