public class CoreConnectionPool extends java.lang.Object implements java.lang.Runnable, ConnectionProvider
It uses threads for opening a new connection. When no connection available it will wait until a connection is released.
Modifier and Type | Class and Description |
---|---|
static class |
CoreConnectionPool.SizeSnapshot
Just a statistic class.
|
Constructor and Description |
---|
CoreConnectionPool() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close all the connections.
|
void |
closeConnection(java.sql.Connection connection)
Dispose of a used
connection . |
java.sql.Connection |
getConnection()
Returns a connection from connection pool.
|
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.
|
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 ConnectionProvider
public java.sql.Connection getConnection()
getConnection
in interface ConnectionProvider
public void run()
run
in interface java.lang.Runnable
public void closeConnection(java.sql.Connection connection)
ConnectionProvider
connection
.closeConnection
in interface ConnectionProvider
public void close()
close
in interface java.lang.AutoCloseable
close
in interface ConnectionProvider
public CoreConnectionPool.SizeSnapshot getConnectionsCount()
Copyright © 2003-present Jodd Team