EAF 7.4 API

com.lutris.appserver.server.sql
Interface DatabaseManager


public interface DatabaseManager

The database management object interface. This class implementing this interface manages the database connections for one application.

Version:
$Revision: 1.3 $
Author:
Paul Morgan

Field Summary
static boolean debug
          Flag to enable debug logging of queries and transactions.
 
Method Summary
 DBConnection allocateConnection()
          Allocate a connection to the default logical database.
 DBConnection allocateConnection(java.lang.String dbName)
          Allocate a connection to the specified logic database.
 ObjectId allocateObjectId()
          Allocate an object id from the specified logical database.
 ObjectId allocateObjectId(java.lang.String dbName)
          Allocate an object id from the specified logical database.
 void checkOId(ObjectId oid)
          Check does oid belong to Object id's range [minOId, currentOId] for default database
 void checkOId(java.lang.String dbName, ObjectId oid)
          Check does oid belong to Object id's range [minOId, currentOId]
 DBQuery createQuery()
          Create a query object for the default logical database.
 DBQuery createQuery(java.lang.String dbName)
          Create a query object for the specified logical database.
 DBTransaction createTransaction()
          Create a transaction object for the default logical database.
 DBTransaction createTransaction(java.lang.String dbName)
          Create a transaction object for the specified logical database.
 LogicalDatabase findLogicalDatabase(java.lang.String dbName)
           
 int getActiveConnectionCount(java.lang.String dbName)
          Returns the number of currently active connections for the supplied logical database name.
 com.lutris.util.Config getConfig()
          Return main configuration class
 java.lang.String getDefaultDB()
          Return default database name (given in config file)
 java.lang.String[] getLogicalDatabaseNames()
          Returns the list of managed logical databases.
 int getMaxConnectionCount(java.lang.String dbName)
          Returns the maximum number of concurent connections that existed at any time since this object was created, or resetMaxConnectionCount() was called.
 java.util.Date getMaxConnectionCountDate(java.lang.String dbName)
          Returns the time when the maximum refered to by maxConnectionCount() occured.
 long getRequestCount(java.lang.String dbName)
          Returns the number of requests made to the database since startup time.
 java.lang.String getType(java.lang.String dbName)
          Returns a description of the logical database type.
 java.lang.String logicalDatabaseType()
          Return a logical database type for the default logical database.
 java.lang.String logicalDatabaseType(java.lang.String dbName)
          Return a logical database type for the default logical database.
 void registerMBeans(java.lang.String appPrefix, com.lutris.util.Config appConfig, java.lang.ClassLoader clsLoader)
           
 void resetMaxConnectionCount(java.lang.String dbName)
          Reset the maximum connection count.
 void setDefaultDatabase(java.lang.String dbName)
          Set the default logical database.
 void shutdown()
          Shutdown the database manager.
 void unregisterMBeans()
           
 

Field Detail

debug

static final boolean debug
Flag to enable debug logging of queries and transactions.

See Also:
Constant Field Values
Method Detail

getConfig

com.lutris.util.Config getConfig()
Return main configuration class

Returns:
main configuration class.

allocateConnection

DBConnection allocateConnection(java.lang.String dbName)
                                throws DatabaseManagerException,
                                       java.sql.SQLException
Allocate a connection to the specified logic database. The connection should be returned to the pool by calling its release() function. A thread will wait if no connections are available. Interupted exceptions are converted to errors.

Parameters:
dbName - Logical name of the database to allocate a connection to.
Returns:
The allocated connection object.
Throws:
DatabaseManagerException - If a nonexistent logical database name is supplied.
java.sql.SQLException - If a SQL error occures.

allocateConnection

DBConnection allocateConnection()
                                throws DatabaseManagerException,
                                       java.sql.SQLException
Allocate a connection to the default logical database. The connection should be returned to the pool by calling its release() function. A thread will wait if no connections are available. Interupted exceptions are converted to errors.

Returns:
The allocated connection object.
Throws:
DatabaseManagerException - If a nonexistent default logical database name is supplied.
java.sql.SQLException - If a SQL error occures.
See Also:
setDefaultDatabase(java.lang.String)

allocateObjectId

ObjectId allocateObjectId(java.lang.String dbName)
                          throws DatabaseManagerException,
                                 ObjectIdException
Allocate an object id from the specified logical database.

Parameters:
dbName - Logical name of the database from which to obtain an object id.
Returns:
The allocated unique OID
Throws:
DatabaseManagerException - If a nonexistent logical database name is supplied.
ObjectIdException - If a problem (e.g. SQL error) occured in obtaining the OID.

allocateObjectId

ObjectId allocateObjectId()
                          throws DatabaseManagerException,
                                 ObjectIdException
Allocate an object id from the specified logical database.

Returns:
The allocated connection object.
Throws:
DatabaseManagerException - If a nonexistent default logical database has been set.
ObjectIdException - If a problem (e.g. SQL error) occured in obtaining the OID.
See Also:
setDefaultDatabase(java.lang.String)

checkOId

void checkOId(java.lang.String dbName,
              ObjectId oid)
              throws DatabaseManagerException,
                     ObjectIdException
Check does oid belong to Object id's range [minOId, currentOId]

Parameters:
dbName - Logical name of the database from which to check an object id.
oid - oid which will be checked.
Throws:
DatabaseManagerException - If a nonexistent logical database name is supplied.
ObjectIdException - If a oid does't belong to range.

checkOId

void checkOId(ObjectId oid)
              throws DatabaseManagerException,
                     ObjectIdException
Check does oid belong to Object id's range [minOId, currentOId] for default database

Parameters:
oid - oid which will be checked.
Throws:
DatabaseManagerException - If a nonexistent default logical database has been set.
ObjectIdException - If a oid does't belong to range.

createTransaction

DBTransaction createTransaction(java.lang.String dbName)
                                throws DatabaseManagerException,
                                       java.sql.SQLException
Create a transaction object for the specified logical database.

Parameters:
dbName - Logical name of the database from which to obtain a transaction.
Returns:
The transaction
Throws:
DatabaseManagerException - If a nonexistent or invalid logical database name is supplied.
java.sql.SQLException - If a problem occured creating the transaction.

createTransaction

DBTransaction createTransaction()
                                throws DatabaseManagerException,
                                       java.sql.SQLException
Create a transaction object for the default logical database.

Returns:
The transaction
Throws:
DatabaseManagerException - If a nonexistent default logical database has been set.
java.sql.SQLException - If a problem occured creating the transaction.
See Also:
setDefaultDatabase(java.lang.String)

createQuery

DBQuery createQuery(java.lang.String dbName)
                    throws DatabaseManagerException,
                           java.sql.SQLException
Create a query object for the specified logical database.

Parameters:
dbName - Logical name of the database from which to obtain a query.
Returns:
The query
Throws:
DatabaseManagerException - If a nonexistent or invalid logical database name is supplied.
java.sql.SQLException - If a problem occured creating the query.

createQuery

DBQuery createQuery()
                    throws DatabaseManagerException,
                           java.sql.SQLException
Create a query object for the default logical database.

Returns:
The query
Throws:
DatabaseManagerException - If a nonexistent default logical database has been set.
java.sql.SQLException - If a problem occured creating the query.
See Also:
setDefaultDatabase(java.lang.String)

logicalDatabaseType

java.lang.String logicalDatabaseType(java.lang.String dbName)
                                     throws DatabaseManagerException,
                                            java.sql.SQLException
Return a logical database type for the default logical database.

Parameters:
dbName - Logical name of the database from which to obtain a query.
Returns:
logical database type
Throws:
DatabaseManagerException - If a nonexistent default logical database has been set.
java.sql.SQLException - If a problem occured creating the query.
See Also:
setDefaultDatabase(java.lang.String)

logicalDatabaseType

java.lang.String logicalDatabaseType()
                                     throws DatabaseManagerException,
                                            java.sql.SQLException
Return a logical database type for the default logical database.

Returns:
logical database type
Throws:
DatabaseManagerException - If a nonexistent default logical database has been set.
java.sql.SQLException - If a problem occured creating the query.
See Also:
setDefaultDatabase(java.lang.String)

setDefaultDatabase

void setDefaultDatabase(java.lang.String dbName)
                        throws DatabaseManagerException
Set the default logical database. This should be used with caution, but it makes allocating connections easier.

Parameters:
dbName - The default logical dabase name.
Throws:
DatabaseManagerException - If a nonexistent or illegal logical database name is supplied.

getDefaultDB

java.lang.String getDefaultDB()
Return default database name (given in config file)

Returns:
default database name

shutdown

void shutdown()
Shutdown the database manager. All logical databases will be shutdown and all connection closed.


getLogicalDatabaseNames

java.lang.String[] getLogicalDatabaseNames()
Returns the list of managed logical databases.

Returns:
List of logical database names.

getType

java.lang.String getType(java.lang.String dbName)
                         throws DatabaseManagerException
Returns a description of the logical database type.

Parameters:
dbName - The logical database name.
Returns:
A text description of the logical database type.
Throws:
DatabaseManagerException - If a nonexistent logical database name is supplied.

getRequestCount

long getRequestCount(java.lang.String dbName)
                     throws DatabaseManagerException
Returns the number of requests made to the database since startup time.

Parameters:
dbName - The logical database name.
Returns:
The number of database requests since the server started.
Throws:
DatabaseManagerException - If a nonexistent logical database name is supplied.

getActiveConnectionCount

int getActiveConnectionCount(java.lang.String dbName)
                             throws DatabaseManagerException
Returns the number of currently active connections for the supplied logical database name. If not implemented, then -1 is returned.

Parameters:
dbName - The logical database name.
Returns:
The number of currently active connections.
Throws:
DatabaseManagerException - If a nonexistent logical database name is supplied.

getMaxConnectionCount

int getMaxConnectionCount(java.lang.String dbName)
                          throws DatabaseManagerException
Returns the maximum number of concurent connections that existed at any time since this object was created, or resetMaxConnectionCount() was called. This is a historical highwater mark. If not implemented, then -1 is returned.

Parameters:
dbName - The logical database name.
Returns:
The highwater mark for number of connections, or -1.
Throws:
DatabaseManagerException - If a nonexistent logical database name is supplied.

getMaxConnectionCountDate

java.util.Date getMaxConnectionCountDate(java.lang.String dbName)
                                         throws DatabaseManagerException
Returns the time when the maximum refered to by maxConnectionCount() occured. If not implemented, then null is returned.

Parameters:
dbName - The logical database name.
Returns:
The Date of when the maximum number of connections occured.
Throws:
DatabaseManagerException - If a nonexistent logical database name is supplied.

resetMaxConnectionCount

void resetMaxConnectionCount(java.lang.String dbName)
                             throws DatabaseManagerException
Reset the maximum connection count. See maxConnectionCount(). The highwater mark should be reset to the current number of connections.

Parameters:
dbName - The logical database name.
Throws:
DatabaseManagerException - If a nonexistent logical database name is supplied.

findLogicalDatabase

LogicalDatabase findLogicalDatabase(java.lang.String dbName)
                                    throws DatabaseManagerException
Throws:
DatabaseManagerException

registerMBeans

void registerMBeans(java.lang.String appPrefix,
                    com.lutris.util.Config appConfig,
                    java.lang.ClassLoader clsLoader)

unregisterMBeans

void unregisterMBeans()

EAF 7.4 API