Klasse 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.
  • Methodendetails

    • getName

      public String getName()
      Rturns the name of the database.
      Gibt zurück:
      the name of the database, not null.
    • getAdapter

      public Adapter getAdapter()
      Returns the adapter to this database.
      Gibt zurück:
      the adapter to this database, or null if no adapter is set.
    • setAdapter

      public void setAdapter(Adapter anAdapter)
      Sets the adapter for this database.
      Parameter:
      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.
      Gibt zurück:
      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.
      Gibt zurück:
      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.
      Parameter:
      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.
      Gibt zurück:
      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.
      Parameter:
      idTable - The TableMap representation for the ID table.
    • setIdTable

      public void setIdTable(String tableName)
      Set the ID table for this database.
      Parameter:
      tableName - The name for the ID table.
    • getIdBroker

      public IDBroker getIdBroker()
      Get the IDBroker for this database.
      Gibt zurück:
      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.
      Gibt zurück:
      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.
      Parameter:
      type - The type (i.e.name) of the IdGenerator.
      Gibt zurück:
      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.
      Parameter:
      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.
      Gibt zurück:
      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.
      Parameter:
      schema - the name of the database schema to set, or null to remove the current schema.