: Interface DatabaseManager

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ModSQL
Interface DatabaseManager

All Known Implementing Classes:
  MetaManager, Manager, Manager, Manager

public interface DatabaseManager

Interface to be implemented by database managers.

To create a new type of database, you need to implement both this interface and the DatabaseTable interface. The primary role of the DatabaseManager is to create DatabaseTable objects when given a table name.

Author:
  chris.studholme@utoronto.ca
See Also:
  `DatabaseTable`

Method Summary
`boolean` | `createIndex(String tablename, String columnname)` Create an index of the specified column in the specified table (if capable).
`DatabaseTable` | `createTable(String tablename, boolean temporary)` Create a new table.
`boolean` | `dropIndex(String tablename, String columnname)` Drop an index.
`void` | `dropTable(String tablename)` Drop a table.
`Function` | `getFunction(String name)` Get a database specific function for use in SQL.
`int` | `getMajorVersion()` Get the driver's major version number.
`int` | `getMinorVersion()` Get the driver's minor version number.
`boolean` | `hasTable(String tablename)` Checks whether this database has the specified table.
`DatabaseTable` | `openTable(String tablename)` Opens the database table with the specified name for read only access.
`DatabaseTable` | `openTable(String tablename, boolean readonly)` Opens the database table with the specified name with read only or read write access.

Method Detail

### getMajorVersion

    public int getMajorVersion()

  Get the driver's major version number. Initially this should be 1.
  Returns:
    major version number

### getMinorVersion

    public int getMinorVersion()

  Get the driver's minor version number. Initially this should be 0.
  Returns:
    minor version number

### hasTable

    public boolean hasTable(String tablename)
                     throws DatabaseException

  Checks whether this database has the specified table.
  Parameters:
    `tablename` - name of the table
  Returns:
    true if the table exists in this database and can be opened, false otherwise
  Throws:
    `DatabaseException` - if a database-access error occurs

### openTable

    public DatabaseTable openTable(String tablename)
                            throws DatabaseException

  Opens the database table with the specified name for read only access.
  Parameters:
    `tablename` - name of the table to open
  Returns:
    a DatabaseTable object representing the table, or null if the table does not exist in this database
  Throws:
    `DatabaseException` - if a database-access error occurs

### openTable

    public DatabaseTable openTable(String tablename,
                                   boolean readonly)
                            throws DatabaseException

  Opens the database table with the specified name with read only or read write access.
  Parameters:
    `tablename` - name of the table to open
    `readonly` - true to open table read only
  Returns:
    a DatabaseTable object representing the table, or null if the table does not exist in this database
  Throws:
    `DatabaseException` - if a database-access error occurs

### createTable

    public DatabaseTable createTable(String tablename,
                                     boolean temporary)
                              throws DatabaseException

  Create a new table. If a table with the given name exists in the database, this method should always throw an exception. If the database is not capable of supporting user created tables, this method should return null.
  Parameters:
    `tablename` - name of the table to create
    `temporary` - table is temporary
  Returns:
    the newly created table opened for read write access, or null if the database doesn't support creating tables
  Throws:
    `DatabaseException` - if a database-access error occurs

### createIndex

    public boolean createIndex(String tablename,
                               String columnname)
                        throws DatabaseException

  Create an index of the specified column in the specified table (if capable).
  Parameters:
    `tablename` - name of the table to index
    `columnname` - name of the column to index
  Returns:
    true if index was created, false if database is not capable of creating indicies
  Throws:
    `DatabaseException` - if a database-access error occurs

### dropTable

    public void dropTable(String tablename)
                   throws DatabaseException

  Drop a table. This method should throw an exception if the table does not exist.
  Parameters:
    `tablename` - name of the table to drop
  Throws:
    `DatabaseException` - if a database-access error occurs

### dropIndex

    public boolean dropIndex(String tablename,
                             String columnname)
                      throws DatabaseException

  Drop an index. This method should throw an exception if the table does not exist, but should return false if the column has not been indexed.
  Parameters:
    `tablename` - name of the table with index
    `columnname` - name of the column with index
  Returns:
    true if the index existed and has been dropped, false if it didn't exist
  Throws:
    `DatabaseException` - if a database-access error occurs

### getFunction

    public Function getFunction(String name)
                         throws DatabaseException

  Get a database specific function for use in SQL. This function may be used in any SQL query (not just queries involving this database's tables). Note that when looking up function names, ModSQL will always check for database specific functions before using built-in functions, so this method may be used to override the built-in SQL functions.

  This method should return null if a function by the specified name is not found.

  Parameters:
    `name` - name of function to lookup (always lowercase)
  Returns:
    new function object (or null if function not found)
  Throws:
    `DatabaseException` - if a database-access error occurs

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD