|
|||||||||
| Home >> All >> com >> lutris >> appserver >> server >> [ sql overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.lutris.appserver.server.sql
Class StandardDatabaseManager

java.lang.Objectcom.lutris.appserver.server.sql.StandardDatabaseManager
- All Implemented Interfaces:
- DatabaseManager
- public class StandardDatabaseManager
- extends java.lang.Object
- implements DatabaseManager
- extends java.lang.Object
The standard database manager implementation. A database manager manages logical databases. It provides a single object from which database connections, object ids (OIDs), transactions and queries can be obtained. The configuration file specifies what logical database to create.
The configuration data is specified as follows:
-
DatabaseManager.Databases- A list of logical SQL database names. -
DatabaseManager.DefaultDatabase- The default logical database used by this application. Optional, if not specified, then the first entry in "DatabaseManager.Databases" is used. -
DatabaseManager.Debug- Specify true to enable Query and Transaction logging, false to disable it. Optional, false if not specified.
DatabaseManager.DB.dbname.
Where dbname is one of the listed logical databases.
DatabaseManager.DB.dbname.ClassType -
This is an optional field which specifies the class of the logical
database implementation or a symbolic name if one on the standard types
are selected. This is recommended because although JDBC abstracts the
data access, the functionality of each database is slightly different
and this parameter allows for optimised usage. The following are
standard types:
- Oracle - For optimized Oracle 7/8 usage.
- Informix - For optimized Informix usage.
- Sybase - For optimized Sybase usage.
- Msql - For optimized Microsoft MSQL usage.
- Standard - For all other JDBC databases. (Default)
- class - For vendor supplied database classes.
Note that since a single SQL user is used to access the database by the entire application, connections maybe kept open, thus saving this overhead on each request. Connections are opened as desired until the maximum configured is reached.
If a thread needs to process a transaction, it requests a connection. If none are available, then a new connection is created up to the configured maximum. A thread is queued waiting for a connection to be returned if a new connection can't be created.
Note also that multiple logical names may map to the same actual database, making it easy to migrate databases if necessary and to provide access through multiple users.
- Since:
- LBS1.8
- Version:
- $Revision: 1.20.12.1 $
| Field Summary | |
protected boolean |
debug
Controls debugging for Transactions and Queries. |
private LogicalDatabase |
defaultLogicalDatabase
Default logical database. |
private java.util.Hashtable |
logicalDatabases
Table of named logical databases. |
| Constructor Summary | |
StandardDatabaseManager(com.lutris.util.Config config)
Creates a new DatabaseManager object and configures
the logical databases defined in the config file. |
|
| Method Summary | |
DBConnection |
allocateConnection()
Allocate a connection to a thread. |
DBConnection |
allocateConnection(java.lang.String dbName)
Allocate a connection to a thread. |
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. |
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. |
private LogicalDatabase |
findLogicalDatabase(java.lang.String dbName)
Find the named logical database in hash table. |
int |
getActiveConnectionCount(java.lang.String dbName)
Gets the number of currently active connections. |
java.lang.String[] |
getLogicalDatabaseNames()
Returns the list of managed logical databases. |
int |
getMaxConnectionCount(java.lang.String dbName)
Gets 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)
Gets the time when the maximum refered to by maxConnectionCount() occured. |
long |
getRequestCount(java.lang.String dbName)
Gets 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. |
LogicalDatabase |
loadLogicalDatabase(java.lang.String dbName,
com.lutris.util.Config dbConfig)
Actually load the specified logical database. |
void |
resetMaxConnectionCount(java.lang.String dbName)
Reset the maximum connection count. |
void |
setDebugLogging(boolean condition)
Turn debugging on or off. |
void |
setDefaultDatabase(java.lang.String dbName)
Set the default logical database. |
void |
shutdown()
Shutdown the database manager. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
logicalDatabases
private java.util.Hashtable logicalDatabases
- Table of named logical databases.
defaultLogicalDatabase
private LogicalDatabase defaultLogicalDatabase
- Default logical database.
debug
protected boolean debug
- Controls debugging for Transactions and Queries.
| Constructor Detail |
StandardDatabaseManager
public StandardDatabaseManager(com.lutris.util.Config config) throws com.lutris.util.ConfigException, DatabaseManagerException, java.sql.SQLException
- Creates a new
DatabaseManagerobject and configures the logical databases defined in the config file.
| Method Detail |
loadLogicalDatabase
public LogicalDatabase loadLogicalDatabase(java.lang.String dbName, com.lutris.util.Config dbConfig) throws DatabaseManagerException
- Actually load the specified logical database. This method provides
an easy way to override the default behavour.
allocateConnection
public DBConnection allocateConnection(java.lang.String dbName) throws DatabaseManagerException, java.sql.SQLException
- Allocate a connection to a thread. The connection should be returned
to the allocator by calling its
release() function. A thread will wait if
no connections are available.
Interupted exceptions are converted to
errors.
N.B. Can't be synchronized, as connection allocator
allocatemay wait.- Specified by:
allocateConnectionin interfaceDatabaseManager
allocateConnection
public DBConnection allocateConnection() throws DatabaseManagerException, java.sql.SQLException
- Allocate a connection to a thread. The connection should be returned
to the allocator by calling its
release() function. A thread will wait if
no connections are available.
Interupted exceptions are converted to
errors. The connection is allocated from the default logical
database.
- Specified by:
allocateConnectionin interfaceDatabaseManager
allocateObjectId
public ObjectId allocateObjectId(java.lang.String dbName) throws DatabaseManagerException, ObjectIdException
- Allocate an object id from the specified logical database.
- Specified by:
allocateObjectIdin interfaceDatabaseManager
allocateObjectId
public ObjectId allocateObjectId() throws DatabaseManagerException, ObjectIdException
- Allocate an object id from the specified logical database.
- Specified by:
allocateObjectIdin interfaceDatabaseManager
createTransaction
public DBTransaction createTransaction(java.lang.String dbName) throws DatabaseManagerException, java.sql.SQLException
- Create a transaction object for the specified logical database.
- Specified by:
createTransactionin interfaceDatabaseManager
createTransaction
public DBTransaction createTransaction() throws DatabaseManagerException, java.sql.SQLException
- Create a transaction object for the default logical database.
- Specified by:
createTransactionin interfaceDatabaseManager
createQuery
public DBQuery createQuery(java.lang.String dbName) throws DatabaseManagerException, java.sql.SQLException
- Create a query object for the specified logical database.
- Specified by:
createQueryin interfaceDatabaseManager
createQuery
public DBQuery createQuery() throws DatabaseManagerException, java.sql.SQLException
- Create a query object for the default logical database.
- Specified by:
createQueryin interfaceDatabaseManager
findLogicalDatabase
private LogicalDatabase findLogicalDatabase(java.lang.String dbName) throws DatabaseManagerException
- Find the named logical database in hash table.
setDefaultDatabase
public void setDefaultDatabase(java.lang.String dbName) throws DatabaseManagerException
- Set the default logical database. This should only be called
after the logical database
(
has been established.
- Specified by:
setDefaultDatabasein interfaceDatabaseManager
shutdown
public void shutdown()
- Shutdown the database manager. All logical databases will be
shutdown and all connections closed.
- Specified by:
shutdownin interfaceDatabaseManager
getLogicalDatabaseNames
public java.lang.String[] getLogicalDatabaseNames()
- Returns the list of managed logical databases.
- Specified by:
getLogicalDatabaseNamesin interfaceDatabaseManager
getType
public java.lang.String getType(java.lang.String dbName) throws DatabaseManagerException
- Returns a description of the logical database type.
- Specified by:
getTypein interfaceDatabaseManager
getRequestCount
public long getRequestCount(java.lang.String dbName) throws DatabaseManagerException
- Gets the number of requests made to the database since startup time.
- Specified by:
getRequestCountin interfaceDatabaseManager
getActiveConnectionCount
public int getActiveConnectionCount(java.lang.String dbName) throws DatabaseManagerException
- Gets the number of currently active connections.
- Specified by:
getActiveConnectionCountin interfaceDatabaseManager
getMaxConnectionCount
public int getMaxConnectionCount(java.lang.String dbName) throws DatabaseManagerException
- Gets 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 you do not implement this feature, return -1.- Specified by:
getMaxConnectionCountin interfaceDatabaseManager
getMaxConnectionCountDate
public java.util.Date getMaxConnectionCountDate(java.lang.String dbName) throws DatabaseManagerException
- Gets the time when the maximum refered to by
maxConnectionCount()occured.- Specified by:
getMaxConnectionCountDatein interfaceDatabaseManager
resetMaxConnectionCount
public 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.- Specified by:
resetMaxConnectionCountin interfaceDatabaseManager
setDebugLogging
public void setDebugLogging(boolean condition)
- Turn debugging on or off.
|
|||||||||
| Home >> All >> com >> lutris >> appserver >> server >> [ sql overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.lutris.appserver.server.sql.StandardDatabaseManager