|
DODS 7.1 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lutris.appserver.server.sql.datasource.DataSourceConnectionAllocator
public class DataSourceConnectionAllocator
Manages a pool (set) of connections to a database. The pool is owned by logical 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. 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 java.lang.String |
connectionAllocateCheckSql
/** database "ConnectionCheckSql" string |
protected java.lang.String |
connectionReleaseCheckSql
database "ConnectionReleaseCheckSql" string |
protected javax.sql.DataSource |
dataSource
JDBC DataSource of database. |
protected boolean |
disableConnectionPool
Indicates dods not to use connection pool. |
protected int |
generation
Generation number. |
protected int |
initWaitingConnections
|
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 int |
maxWaitingConnections
JP Patch Maximum number of DBConnections that will be waiting in the pool |
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 java.lang.String |
shutDownStr
database "ShutDown" string |
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 | |
---|---|
DataSourceConnectionAllocator(LogicalDatabase logicalDatabase,
Config conConfig)
/** Creates instance of StandardConnectionAllocator object. |
Method Summary | |
---|---|
DBConnection |
allocate()
Allocate new connection from pool. |
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. |
java.lang.String |
getDatabaseName()
|
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 |
IncrementRequesteCount()
|
boolean |
performRollbackOnReset()
|
void |
release(DBConnection dbConnection)
|
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 javax.sql.DataSource dataSource
protected java.lang.String shutDownStr
protected java.lang.String url
protected java.lang.String user
protected java.lang.String password
protected java.lang.String connectionAllocateCheckSql
protected java.lang.String connectionReleaseCheckSql
protected long numRequests
protected int maxWaitingConnections
protected int initWaitingConnections
protected boolean sqlLogging
protected boolean disableConnectionPool
protected int queryTimeOut
protected int transactionTimeOut
protected int maxPreparedStatements
protected int generation
Constructor Detail |
---|
public DataSourceConnectionAllocator(LogicalDatabase logicalDatabase, Config conConfig) throws ConfigException
logicalDatabase
- LogicalDatabase that is owner of this ConnectionAllocator
object.conConfig
- Connection allocator configuration object.
ConfigException
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
ConnectionAllocator.allocate()
public void release(DBConnection dbConnection)
release
in interface ConnectionAllocator
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
public java.lang.String getDatabaseName()
getDatabaseName
in interface ConnectionAllocator
public void IncrementRequesteCount()
IncrementRequesteCount
in interface ExtendedConnectionAllocator
public boolean performRollbackOnReset()
performRollbackOnReset
in interface ExtendedConnectionAllocator
|
DODS 7.1 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |