|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.lang.Thread
|
+--amber.server.manager.database.ConnectionPool
This class controls a cache of connection pools. It is instantiated by the Database Manager and coordinates connections to a database and the interaction to the database system.
DatabaseManager,
DatabaseConnection| Field Summary | |
protected java.util.Vector |
connectionPool
The connection pool |
static long |
ConnectionWaitQuanta
How many milliseconds to block before rechecking an event. |
protected java.lang.String |
databaseDriver
The name of the database driver. |
protected java.lang.String |
databaseName
The name of the database URL. |
static java.lang.String |
header
|
protected long |
inactivityDuration
The amount of time the thread should sleep between refreshing connections. |
protected Log |
loggingFile
Logging file. |
protected int |
maxConnections
The maximum number of connections to ever establish. |
protected int |
minConnections
The minimum number of connections to establish on start up. |
protected java.lang.String |
password
The password to use when connecting to the database. |
protected java.lang.String |
userName
The user name to use when connecting to the database. |
static java.lang.String |
version
|
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
ConnectionPool(java.lang.String name,
java.lang.String databaseDriver,
java.lang.String databaseName,
java.lang.String userName,
java.lang.String password,
int minConnections,
int maxConnections,
java.lang.String logFilename,
int logLevel,
long inactivityDuration)
The constructor for the pool. |
|
| Method Summary | |
protected DatabaseConnection |
createNewConnection(java.lang.String databaseName,
java.lang.String userName,
java.lang.String password)
This function creates a new connection and adds it to the pool of available database objects. |
boolean |
equals(java.lang.Object other)
This function determines if the input object is the same as this object. |
int |
getAvailableConnections()
Return the number of available connections. |
java.sql.Connection |
getConnection()
Gets a connection from the available connection pool. |
java.sql.Connection |
getConnection(long timeout)
Gets a connection from the available connection pool. |
int |
getMaximumConnections()
Return the maximum number of connections which it is possible to raise. |
int |
getMinimumConnections()
Return the minimum number of connections raised on creation. |
java.lang.String |
getPoolName()
This function returns the name of the ConnectionPool. |
int |
getTotalConnections()
Return the total number of connections raised currently to the database. |
void |
init(java.lang.String logFilename,
int logLevel)
Main initialisation function for this database system. |
protected void |
initialiseDataBase(java.lang.String databaseDriver,
java.lang.String databaseName,
java.lang.String userName,
java.lang.String password)
This function opens the database given the specified characteristics. |
protected java.sql.Connection |
openConnection(java.lang.String databaseName,
java.lang.String userName,
java.lang.String password)
This function opens a new connection to the database. |
protected void |
openConnections(java.lang.String databaseName,
java.lang.String userName,
java.lang.String password)
This function opens the specified number of connections in the properties file for the manager. |
protected void |
refreshConnection(DatabaseConnection entry)
This function refreshes an individual connection pool entry. |
void |
refreshConnectionPool()
This function refreshes the connection pool and ensures that the connections are still valid. |
void |
releaseConnection(java.sql.Connection connection)
Returns the connection back to the available connection pool. |
void |
run()
The thread run method. |
void |
shutDown()
Termination function. |
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final java.lang.String version
public static final java.lang.String header
public static final long ConnectionWaitQuanta
protected Log loggingFile
protected java.util.Vector connectionPool
protected java.lang.String databaseName
protected java.lang.String databaseDriver
protected java.lang.String userName
protected java.lang.String password
protected int minConnections
protected int maxConnections
protected long inactivityDuration
| Constructor Detail |
public ConnectionPool(java.lang.String name,
java.lang.String databaseDriver,
java.lang.String databaseName,
java.lang.String userName,
java.lang.String password,
int minConnections,
int maxConnections,
java.lang.String logFilename,
int logLevel,
long inactivityDuration)
throws DatabaseManagerException
name - String containing the name of the connection pool object.databaseDriver - String name of the JDBC driver.databaseName - String JDBC URL of the database.userName - String name to use when authenticating this server.password - String password to use when authenticating this server.minConnections - int number of connections to start pool with.maxConnections - int number of upper limit of connections to create.logFilename - String containing the name of the log file.logLevel - int containing the log level to log.inactivityDuration - long time that the thread should sleep between refreshes.DatabaseManagerException - containing errors.| Method Detail |
public void init(java.lang.String logFilename,
int logLevel)
throws DatabaseManagerException
logFilename - String containing the name of the log file.logLevel - int containing the log level to log.DatabaseManagerException - containing errors.
protected void initialiseDataBase(java.lang.String databaseDriver,
java.lang.String databaseName,
java.lang.String userName,
java.lang.String password)
throws DatabaseManagerException
databaseDriver - String name of the JDBC driver.databaseName - String JDBC URL of the database.userName - String name to use when authenticating this server.password - String password to use when authenticating this server.DatabaseManagerException - containing errors.
protected void openConnections(java.lang.String databaseName,
java.lang.String userName,
java.lang.String password)
throws DatabaseManagerException
databaseName - String JDBC URL of the database.userName - String name to use when authenticating this server.password - String password to use when authenticating this server.DatabaseManagerException - containing errors.
protected DatabaseConnection createNewConnection(java.lang.String databaseName,
java.lang.String userName,
java.lang.String password)
databaseName - String JDBC URL of the database.userName - String name to use when authenticating this server.password - String password to use when authenticating this server.
protected java.sql.Connection openConnection(java.lang.String databaseName,
java.lang.String userName,
java.lang.String password)
databaseName - String JDBC URL of the database.userName - String name to use when authenticating this server.password - String password to use when authenticating this server.public java.sql.Connection getConnection(long timeout)
timeout - long time in milliseconds to wait for the connection to
become available.public java.sql.Connection getConnection()
public void releaseConnection(java.sql.Connection connection)
connection - Connection to return to the pool.public int getTotalConnections()
public int getMinimumConnections()
public int getMaximumConnections()
public int getAvailableConnections()
public void refreshConnectionPool()
protected void refreshConnection(DatabaseConnection entry)
entry - DatabaseConnection to refresh.public void run()
run in class java.lang.Threadpublic void shutDown()
public java.lang.String getPoolName()
public boolean equals(java.lang.Object other)
equals in class java.lang.Objectother - Object to match against.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||