|
Enhydra 5.1 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.lutris.appserver.server.sql.standard.StandardConnectionAllocator
Manages a pool (set) of connections to a database. The pool is named as a logical database. By naming a pool, this allows connection resource control to be on a finer grain that a database and allows for easier migration to multiple databases. One or more pools can map to the same actual database. A connection considered part of the pool, even if its allocated to a thread. These objects are all publicly accessed via the Database Manager, not directly.
If an error occurs in a connection, it is dropped from the pool. The process using the connection has already received an error which aborts the work in progress. By dropping the connection, waiting threads are restarted. If something is wrong with the database (e.g. server is down), they will recieve errors and also be aborted. A generation number is used to close down all connections that were open when the error occured, allowing new connections to be allocated.
The configuration data is specified in the section:
DatabaseManager.DB.dbName.Connection
Configuration sub fields are:
Url
-
The JDBC URLof the database. Manditary.
E.g. "jdbc:sequelink://dbHost:4000/[Informix];Database=dummy"
User
-
The database users used to access the database. Manditary.
Password
-
The database user's password. Manditary.
MaxPoolSize
-
The maximum number of open connections to the database. Optional,
if not specified, then it default to 0. A value of 0 means that
connections are allocated indefinitely or until the database (JDBC)
refuses any new connections.
Logging
-
Specify true to enable SQL logging, false to disable it. Optional,
false if not specified.
AllocationTimeout
-
The Maximum amount of time that a thread will wait for
a connection from the connection allocator before an exception is
thrown. This will prevent possible dead locks. The time out is in
milliseconds. If the time out is <= 0, the allocation of connections
will wait indefinitely. Optional, if not specified, then it
defaults to 1000 (ms).
QueryTimeout
- The amount of time (in seconds) that
a query will block before throwing an exception. If <= 0 then the
query will not block. Optional, if not specified, then the value
defaults to 0. This is not implemented by all logical databases.
TransactionTimeout
- The amount of time (in seconds)
that a transaction will block before throwing an exception. If
<= 0 then the transaction will not block. Optional, if not specified,
then the value defaults to 0. This is not implemented by all
logical databases.
MaxPreparedStatements
- If specified, overrides
the JDBC Connection.getMetaData().getMaxStatements()
value. If less than zero, use the meta data value. Optional,
default is to use the meta data.
Field Summary | |
protected int |
generation
Generation number. |
protected LogicalDatabase |
logicalDatabase
Reference to the logical database for easy access to the connection pool. |
protected int |
maxPreparedStatements
Maximum number of prepared statements to use; if less-than zero, then JDBC is queried for this value. |
protected long |
numRequests
Number of queries or transactions on this logical database. |
protected java.lang.String |
password
SQL password.. |
protected int |
queryTimeOut
Maximum amount of time in seconds to block on a query. |
protected boolean |
sqlLogging
Indicates if logging is enabled. |
protected int |
transactionTimeOut
Maximum amount of time in seconds to block on a transaction. |
protected java.lang.String |
url
JDBC URL of database. |
protected java.lang.String |
user
SQL user name. |
Constructor Summary | |
protected |
StandardConnectionAllocator(LogicalDatabase logicalDatabase,
Config conConfig)
Initialize the connection allocator object. |
Method Summary | |
DBConnection |
allocate()
Allocate a connection to a thread. |
protected DBConnection |
createConnection()
Create a new connection in the pool. |
void |
drop(DBConnection dbConnection)
Called when a connection in this pool has an SQL error. |
void |
dropAllNow()
Called when the database manager is shutting down: Close all connections immediately. |
protected void |
finalize()
Finalizer. |
int |
getActiveCount()
Return the number of currently active connections. |
int |
getMaxCount()
Return the maximum number of connections active at one time. |
java.util.Date |
getMaxCountDate()
Return the time when the maximum connection count occured. |
long |
getRequestCount()
Return the number of database requests. |
void |
release(DBConnection dbConnection)
Return a connection to the pool. |
void |
resetMaxCount()
Reset the maximum connection count and date. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected LogicalDatabase logicalDatabase
protected java.lang.String url
protected java.lang.String user
protected java.lang.String password
protected long numRequests
protected boolean sqlLogging
protected int queryTimeOut
protected int transactionTimeOut
protected int maxPreparedStatements
protected int generation
Constructor Detail |
protected StandardConnectionAllocator(LogicalDatabase logicalDatabase, Config conConfig) throws ConfigException
ConfigException
- if bad configuration information is
given in the config file.Method Detail |
protected DBConnection createConnection() throws java.sql.SQLException
java.sql.SQLException
- If a SQL error occures.public DBConnection allocate() throws java.sql.SQLException
allocate
in interface ConnectionAllocator
java.sql.SQLException
- If a SQL error occures.
java.sql.SQLException
- if a SQL error occures.public void release(DBConnection dbConnection)
release
in interface ConnectionAllocator
dbConnection
- The connection object to return.public void drop(DBConnection dbConnection)
drop
in interface ConnectionAllocator
dbConnection
- The connection object to drop.
The connection should be
returned to the pool after this function returns.public void dropAllNow()
dropAllNow
in interface ConnectionAllocator
public int getActiveCount()
getActiveCount
in interface ConnectionAllocator
public int getMaxCount()
getMaxCount
in interface ConnectionAllocator
public java.util.Date getMaxCountDate()
getMaxCountDate
in interface ConnectionAllocator
Date
when the maximum connection
count occured.public void resetMaxCount()
resetMaxCount
in interface ConnectionAllocator
public long getRequestCount()
getRequestCount
in interface ConnectionAllocator
protected void finalize()
finalize
in class java.lang.Object
|
Enhydra 5.1 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |