|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectutil.sql.ConnectionManager
public class ConnectionManager
creates a pool of connections to DB for performance reasons
Field Summary | |
---|---|
private java.util.Vector<java.sql.Connection> |
connectionPool
|
private java.lang.String |
databaseUrl
|
private java.lang.String |
driver
|
private int |
MAX_POOL_SIZE
|
private java.lang.String |
password
|
private java.lang.String |
username
|
Constructor Summary | |
---|---|
ConnectionManager()
Constructor default |
|
ConnectionManager(java.lang.String driver,
java.lang.String databaseUrl,
java.lang.String username,
java.lang.String password,
int maxPoolSize)
|
Method Summary | |
---|---|
private boolean |
checkIfConnectionPoolIsFull()
|
boolean |
connectionSuccess()
|
private java.sql.Connection |
createNewConnectionForPool()
creates new connection to db |
java.sql.Connection |
getConnectionFromPool()
|
private void |
initializeConnectionPool()
fills connectionPool with connections for numConnections < MAX_POOL_SIZE |
void |
returnConnectionToPool(java.sql.Connection connection)
Adding the connection from the client back to the connectionPool |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.lang.String driver
private java.lang.String databaseUrl
private java.lang.String username
private java.lang.String password
private java.util.Vector<java.sql.Connection> connectionPool
private int MAX_POOL_SIZE
Constructor Detail |
---|
public ConnectionManager()
public ConnectionManager(java.lang.String driver, java.lang.String databaseUrl, java.lang.String username, java.lang.String password, int maxPoolSize)
driver
- which dbc driverdatabaseUrl
- -username
- -password
- -maxPoolSize
- - how many db-connection should the ConnectionManager allocateMethod Detail |
---|
private void initializeConnectionPool()
private boolean checkIfConnectionPoolIsFull()
private java.sql.Connection createNewConnectionForPool()
public java.sql.Connection getConnectionFromPool()
public void returnConnectionToPool(java.sql.Connection connection)
connection
- -public boolean connectionSuccess()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |