|
Enhydra 3.1 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.lutris.appserver.server.sql.StandardDatabaseManager
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:
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.
Field Summary | |
protected boolean |
debug
Controls debugging for Transactions and Queries. |
Fields inherited from interface com.lutris.appserver.server.sql.DatabaseManager |
debug |
Constructor Summary | |
StandardDatabaseManager(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. |
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,
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 |
protected boolean debug
Constructor Detail |
public StandardDatabaseManager(Config config) throws ConfigException, DatabaseManagerException, java.sql.SQLException
DatabaseManager
object and configures
the logical databases defined in the config file.config
- The configuration data for logical databases.Method Detail |
public LogicalDatabase loadLogicalDatabase(java.lang.String dbName, Config dbConfig) throws DatabaseManagerException
public DBConnection allocateConnection(java.lang.String dbName) throws DatabaseManagerException, java.sql.SQLException
allocate
may wait.dbName
- Logical name of the database to allocate a connection to.public DBConnection allocateConnection() throws DatabaseManagerException, java.sql.SQLException
setDefaultDatabase(java.lang.String)
public ObjectId allocateObjectId(java.lang.String dbName) throws DatabaseManagerException, ObjectIdException
name
- Logical name of the database from which to obtain an object id.public ObjectId allocateObjectId() throws DatabaseManagerException, ObjectIdException
setDefaultDatabase(java.lang.String)
public DBTransaction createTransaction(java.lang.String dbName) throws DatabaseManagerException, java.sql.SQLException
dbName
- Logical name of the database from which to obtain a transaction.public DBTransaction createTransaction() throws DatabaseManagerException, java.sql.SQLException
dbName
- Logical name of the database from which to obtain a transaction.setDefaultDatabase(java.lang.String)
public DBQuery createQuery(java.lang.String dbName) throws DatabaseManagerException, java.sql.SQLException
dbName
- Logical name of the database from which to obtain a query.public DBQuery createQuery() throws DatabaseManagerException, java.sql.SQLException
dbName
- Logical name of the database from which to obtain a query.setDefaultDatabase(java.lang.String)
public void setDefaultDatabase(java.lang.String dbName) throws DatabaseManagerException
dbName
- The default logical database.public void shutdown()
public java.lang.String[] getLogicalDatabaseNames()
public java.lang.String getType(java.lang.String dbName) throws DatabaseManagerException
dbName
- The logical database name.public long getRequestCount(java.lang.String dbName) throws DatabaseManagerException
The
- name of the logical database.public int getActiveConnectionCount(java.lang.String dbName) throws DatabaseManagerException
dbName
- The name of the logical database.public int getMaxConnectionCount(java.lang.String dbName) throws DatabaseManagerException
resetMaxConnectionCount()
was called.
This is a historical highwater mark.
If you do not implement this feature, return -1.dbName
- The name of the logical database.public java.util.Date getMaxConnectionCountDate(java.lang.String dbName) throws DatabaseManagerException
maxConnectionCount()
occured.dbName
- The name of the logical database.public void resetMaxConnectionCount(java.lang.String dbName) throws DatabaseManagerException
maxConnectionCount()
. The highwater mark should be
reset to the current number of connections.dbName
- The name of the logical database.public void setDebugLogging(boolean condition)
condition
- on of off.
|
Enhydra 3.1 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |