public class DataSourceConfig extends Object
| Constructor and Description |
|---|
DataSourceConfig() |
| Modifier and Type | Method and Description |
|---|---|
DataSourceAlert |
getAlert()
Return the alert implementation to use.
|
int |
getCstmtCacheSize()
Return the size of the CallableStatement cache (per connection).
|
Map<String,String> |
getCustomProperties()
Return a map of custom properties for the jdbc driver connection.
|
String |
getDriver()
Return the database driver.
|
int |
getHeartbeatFreqSecs()
Return the heartbeat frequency in seconds.
|
String |
getHeartbeatSql()
Return a SQL statement used to test the database is accessible.
|
int |
getHeartbeatTimeoutSeconds()
Return the heart beat timeout in seconds.
|
int |
getIsolationLevel()
Return the transaction isolation level.
|
int |
getLeakTimeMinutes()
Return the time in minutes after which a connection could be considered to
have leaked.
|
DataSourcePoolListener |
getListener()
Return the listener to use.
|
int |
getMaxAgeMinutes()
Return the maximum age a connection is allowed to be before it is closed.
|
int |
getMaxConnections()
Return the maximum number of connections the pool can reach.
|
int |
getMaxInactiveTimeSecs()
Return the time in seconds a connection can be idle after which it can be
trimmed from the pool.
|
int |
getMaxStackTraceSize()
Return the max size for reporting stack traces on busy connections.
|
int |
getMinConnections()
Return the minimum number of connections the pool should maintain.
|
String |
getPassword()
Return the database password.
|
String |
getPoolListener()
Return the pool listener.
|
int |
getPstmtCacheSize()
Return the size of the PreparedStatement cache (per connection).
|
int |
getTrimPoolFreqSecs()
Return the minimum time gap between pool trim checks.
|
String |
getUrl()
Return the connection URL.
|
String |
getUsername()
Return the database username.
|
int |
getWaitTimeoutMillis()
Return the time in millis to wait for a connection before timing out once
the pool has reached its maximum size.
|
boolean |
isAutoCommit()
Return autoCommit setting.
|
boolean |
isCaptureStackTrace()
Return true if a stack trace should be captured when obtaining a connection
from the pool.
|
boolean |
isEmpty()
Return true if there are no values set for any of url, driver, username and password.
|
boolean |
isOffline()
Return true if the DataSource should be left offline.
|
boolean |
isReadOnly()
Return the read only setting.
|
void |
loadSettings(Properties properties,
String serverName)
Load the settings from the properties supplied.
|
void |
setAlert(DataSourceAlert alert)
Set the alert implementation to use.
|
void |
setAutoCommit(boolean autoCommit)
Set to true to turn on autoCommit.
|
void |
setCaptureStackTrace(boolean captureStackTrace)
Set to true if a stack trace should be captured when obtaining a connection
from the pool.
|
void |
setCstmtCacheSize(int cstmtCacheSize)
Set the size of the CallableStatement cache (per connection).
|
void |
setCustomProperties(Map<String,String> customProperties)
Set custom properties for the jdbc driver connection.
|
void |
setDefaults(DataSourceConfig other)
Default the values for driver, url, username and password from another config if
they have not been set.
|
void |
setDriver(String driver)
Set the database driver.
|
void |
setHeartbeatFreqSecs(int heartbeatFreqSecs)
Set the expected heartbeat frequency in seconds.
|
void |
setHeartbeatSql(String heartbeatSql)
Set a SQL statement used to test the database is accessible.
|
void |
setHeartbeatTimeoutSeconds(int heartbeatTimeoutSeconds)
Set the heart beat timeout in seconds.
|
void |
setIsolationLevel(int isolationLevel)
Set the transaction isolation level.
|
void |
setLeakTimeMinutes(int leakTimeMinutes)
Set the time in minutes after which a connection could be considered to
have leaked.
|
void |
setListener(DataSourcePoolListener listener)
Set the listener to use.
|
void |
setMaxAgeMinutes(int maxAgeMinutes)
Set the maximum age a connection can be in minutes.
|
void |
setMaxConnections(int maxConnections)
Set the maximum number of connections the pool can reach.
|
void |
setMaxInactiveTimeSecs(int maxInactiveTimeSecs)
Set the time in seconds a connection can be idle after which it can be
trimmed from the pool.
|
void |
setMaxStackTraceSize(int maxStackTraceSize)
Set the max size for reporting stack traces on busy connections.
|
void |
setMinConnections(int minConnections)
Set the minimum number of connections the pool should maintain.
|
void |
setOffline(boolean offline)
Set to true if the DataSource should be left offline.
|
void |
setPassword(String password)
Set the database password.
|
void |
setPoolListener(String poolListener)
Set a pool listener.
|
void |
setPstmtCacheSize(int pstmtCacheSize)
Set the size of the PreparedStatement cache (per connection).
|
void |
setReadOnly(boolean readOnly)
Set to true to for read only.
|
void |
setTrimPoolFreqSecs(int trimPoolFreqSecs)
Set the minimum trim gap between pool trim checks.
|
void |
setUrl(String url)
Set the connection URL.
|
void |
setUsername(String username)
Set the database username.
|
void |
setWaitTimeoutMillis(int waitTimeoutMillis)
Set the time in millis to wait for a connection before timing out once the
pool has reached its maximum size.
|
public DataSourceConfig()
public void setDefaults(DataSourceConfig other)
public boolean isEmpty()
public String getUsername()
public void setUsername(String username)
public String getPassword()
public void setPassword(String password)
public int getIsolationLevel()
public void setIsolationLevel(int isolationLevel)
public boolean isAutoCommit()
public void setAutoCommit(boolean autoCommit)
public boolean isReadOnly()
public void setReadOnly(boolean readOnly)
public int getMinConnections()
public void setMinConnections(int minConnections)
public int getMaxConnections()
public void setMaxConnections(int maxConnections)
public DataSourceAlert getAlert()
public void setAlert(DataSourceAlert alert)
public DataSourcePoolListener getListener()
public void setListener(DataSourcePoolListener listener)
public String getHeartbeatSql()
Note that if this is not set then it can get defaulted from the DatabasePlatform.
public void setHeartbeatSql(String heartbeatSql)
Note that if this is not set then it can get defaulted from the DatabasePlatform.
public int getHeartbeatFreqSecs()
This is the expected frequency in which the DataSource should be checked to make sure it is healthy and trim idle connections.
public void setHeartbeatFreqSecs(int heartbeatFreqSecs)
public int getHeartbeatTimeoutSeconds()
public void setHeartbeatTimeoutSeconds(int heartbeatTimeoutSeconds)
public boolean isCaptureStackTrace()
This can be used to diagnose a suspected connection pool leak.
Obviously this has a performance overhead.
public void setCaptureStackTrace(boolean captureStackTrace)
This can be used to diagnose a suspected connection pool leak.
Obviously this has a performance overhead.
public int getMaxStackTraceSize()
public void setMaxStackTraceSize(int maxStackTraceSize)
public int getLeakTimeMinutes()
public void setLeakTimeMinutes(int leakTimeMinutes)
public int getPstmtCacheSize()
public void setPstmtCacheSize(int pstmtCacheSize)
public int getCstmtCacheSize()
public void setCstmtCacheSize(int cstmtCacheSize)
public int getWaitTimeoutMillis()
public void setWaitTimeoutMillis(int waitTimeoutMillis)
public int getMaxInactiveTimeSecs()
This is so that the pool after a busy period can trend over time back towards the minimum connections.
public int getMaxAgeMinutes()
This can be used to close really old connections.
public void setMaxAgeMinutes(int maxAgeMinutes)
public void setMaxInactiveTimeSecs(int maxInactiveTimeSecs)
This is so that the pool after a busy period can trend over time back towards the minimum connections.
public int getTrimPoolFreqSecs()
This defaults to 59 seconds meaning that the pool trim check will run every minute assuming the heart beat check runs every 30 seconds.
public void setTrimPoolFreqSecs(int trimPoolFreqSecs)
public String getPoolListener()
public void setPoolListener(String poolListener)
public boolean isOffline()
This is to support DDL generation etc without having a real database.
public void setOffline(boolean offline)
public Map<String,String> getCustomProperties()
public void setCustomProperties(Map<String,String> customProperties)
public void loadSettings(Properties properties, String serverName)
You can use this when you have your own properties to use for configuration.
properties - the properties to configure the dataSourceserverName - the name of the specific dataSource (optional)Copyright © 2018. All rights reserved.