|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjodd.db.pool.CoreConnectionPool
public class CoreConnectionPool
A class for pre-allocating, recycling, and managing JDBC connections.
It uses threads for opening a new connection. When no connection available it will wait until a connection is released.
| Nested Class Summary | |
|---|---|
static class |
CoreConnectionPool.SizeSnapshot
Just a statistic class. |
| Constructor Summary | |
|---|---|
CoreConnectionPool()
|
|
| Method Summary | |
|---|---|
void |
close()
Close all the connections. |
void |
closeConnection(java.sql.Connection connection)
Dispose of a used connection. |
java.sql.Connection |
getConnection()
Get a connection. |
CoreConnectionPool.SizeSnapshot |
getConnectionsCount()
Returns connection stats. |
java.lang.String |
getDriver()
|
int |
getMaxConnections()
|
int |
getMinConnections()
|
java.lang.String |
getPassword()
|
java.lang.String |
getUrl()
|
java.lang.String |
getUser()
|
java.lang.String |
getValidationQuery()
|
long |
getValidationTimeout()
|
void |
init()
Initialize the connection provider. |
boolean |
isValidateConnection()
|
boolean |
isWaitIfBusy()
|
void |
run()
|
void |
setDefaultValidationQuery()
Sets default validation query (select 1); |
void |
setDriver(java.lang.String driver)
Specifies driver class name. |
void |
setMaxConnections(int maxConnections)
Sets max number of connections. |
void |
setMinConnections(int minConnections)
Sets minimum number of open connections. |
void |
setPassword(java.lang.String password)
Specifies db password. |
void |
setUrl(java.lang.String url)
Specifies JDBC url. |
void |
setUser(java.lang.String user)
Specifies db username. |
void |
setValidateConnection(boolean validateConnection)
Specifies if connections should be validated before returned. |
void |
setValidationQuery(java.lang.String validationQuery)
Specifies query to be used for validating connections. |
void |
setValidationTimeout(long validationTimeout)
Specifies number of milliseconds from connection creation when connection is considered as opened and valid. |
void |
setWaitIfBusy(boolean waitIfBusy)
Sets if pool should wait for connection to be freed when none is available. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CoreConnectionPool()
| Method Detail |
|---|
public java.lang.String getDriver()
public void setDriver(java.lang.String driver)
public java.lang.String getUrl()
public void setUrl(java.lang.String url)
public java.lang.String getUser()
public void setUser(java.lang.String user)
public java.lang.String getPassword()
public void setPassword(java.lang.String password)
public int getMaxConnections()
public void setMaxConnections(int maxConnections)
public int getMinConnections()
public void setMinConnections(int minConnections)
public boolean isWaitIfBusy()
public void setWaitIfBusy(boolean waitIfBusy)
false
exception will be thrown when max connection is reached.
public long getValidationTimeout()
public void setValidationTimeout(long validationTimeout)
public java.lang.String getValidationQuery()
public void setValidationQuery(java.lang.String validationQuery)
null validation will be performed
by invoking Connection#isClosed method.
public void setDefaultValidationQuery()
public boolean isValidateConnection()
public void setValidateConnection(boolean validateConnection)
public void init()
init in interface ConnectionProviderpublic java.sql.Connection getConnection()
getConnection in interface ConnectionProviderpublic void run()
run in interface java.lang.Runnablepublic void closeConnection(java.sql.Connection connection)
ConnectionProvider
closeConnection in interface ConnectionProviderpublic void close()
close in interface ConnectionProviderpublic CoreConnectionPool.SizeSnapshot getConnectionsCount()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||