public class DataSourceConfig extends Object
| Constructor and Description |
|---|
DataSourceConfig() |
| Modifier and Type | Method and Description |
|---|---|
DataSourceConfig |
copy()
Return a copy of the DataSourceConfig.
|
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.
|
InitDatabase |
getInitDatabase()
Return the InitDatabase to use with ownerUsername.
|
List<String> |
getInitSql()
Return a list of init queries, that are executed after a connection is opened.
|
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 |
getOwnerPassword()
Return the database owner password.
|
String |
getOwnerUsername()
Return the database owner username.
|
String |
getPassword()
Return the database password.
|
String |
getPlatform()
Return the database platform.
|
String |
getPoolListener()
Return the pool listener.
|
int |
getPstmtCacheSize()
Return the size of the PreparedStatement cache (per connection).
|
String |
getSchema()
Return the database username.
|
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 |
isFailOnStart()
Return true (default) if the DataSource should be fail on start.
|
boolean |
isOffline()
Return true if the DataSource should be left offline.
|
boolean |
isReadOnly()
Return the read only setting.
|
DataSourceConfig |
loadSettings(Properties properties,
String serverName)
Load the settings from the properties supplied.
|
DataSourceConfig |
setAlert(DataSourceAlert alert)
Set the alert implementation to use.
|
DataSourceConfig |
setAutoCommit(boolean autoCommit)
Set to true to turn on autoCommit.
|
DataSourceConfig |
setCaptureStackTrace(boolean captureStackTrace)
Set to true if a stack trace should be captured when obtaining a connection
from the pool.
|
DataSourceConfig |
setCstmtCacheSize(int cstmtCacheSize)
Set the size of the CallableStatement cache (per connection).
|
DataSourceConfig |
setCustomProperties(Map<String,String> customProperties)
Set custom properties for the jdbc driver connection.
|
DataSourceConfig |
setDefaults(DataSourceConfig other)
Default the values for driver, url, username and password from another config if
they have not been set.
|
DataSourceConfig |
setDriver(String driver)
Set the database driver.
|
DataSourceConfig |
setFailOnStart(boolean failOnStart)
Set to false, if DataSource should not fail on start.
|
DataSourceConfig |
setHeartbeatFreqSecs(int heartbeatFreqSecs)
Set the expected heartbeat frequency in seconds.
|
DataSourceConfig |
setHeartbeatSql(String heartbeatSql)
Set a SQL statement used to test the database is accessible.
|
DataSourceConfig |
setHeartbeatTimeoutSeconds(int heartbeatTimeoutSeconds)
Set the heart beat timeout in seconds.
|
DataSourceConfig |
setInitDatabase(InitDatabase initDatabase)
Set the InitDatabase to use with ownerUsername.
|
DataSourceConfig |
setInitDatabaseForPlatform(String platform)
Set InitDatabase based on the database platform.
|
DataSourceConfig |
setInitSql(List<String> initSql)
Set custom init queries for each query.
|
DataSourceConfig |
setIsolationLevel(int isolationLevel)
Set the transaction isolation level.
|
DataSourceConfig |
setLeakTimeMinutes(int leakTimeMinutes)
Set the time in minutes after which a connection could be considered to
have leaked.
|
DataSourceConfig |
setListener(DataSourcePoolListener listener)
Set the listener to use.
|
DataSourceConfig |
setMaxAgeMinutes(int maxAgeMinutes)
Set the maximum age a connection can be in minutes.
|
DataSourceConfig |
setMaxConnections(int maxConnections)
Set the maximum number of connections the pool can reach.
|
DataSourceConfig |
setMaxInactiveTimeSecs(int maxInactiveTimeSecs)
Set the time in seconds a connection can be idle after which it can be
trimmed from the pool.
|
DataSourceConfig |
setMaxStackTraceSize(int maxStackTraceSize)
Set the max size for reporting stack traces on busy connections.
|
DataSourceConfig |
setMinConnections(int minConnections)
Set the minimum number of connections the pool should maintain.
|
DataSourceConfig |
setOffline(boolean offline)
Set to true if the DataSource should be left offline.
|
DataSourceConfig |
setOwnerPassword(String ownerPassword)
Set the database owner password (used to create connection for use with InitDatabase).
|
DataSourceConfig |
setOwnerUsername(String ownerUsername)
Set the database owner username (used to create connection for use with InitDatabase).
|
DataSourceConfig |
setPassword(String password)
Set the database password.
|
DataSourceConfig |
setPlatform(String platform)
Set the database platform (for use with ownerUsername and InitDatabase.
|
DataSourceConfig |
setPoolListener(String poolListener)
Set a pool listener.
|
DataSourceConfig |
setPstmtCacheSize(int pstmtCacheSize)
Set the size of the PreparedStatement cache (per connection).
|
DataSourceConfig |
setReadOnly(boolean readOnly)
Set to true to for read only.
|
DataSourceConfig |
setSchema(String schema)
Set the default database schema to use.
|
DataSourceConfig |
setTrimPoolFreqSecs(int trimPoolFreqSecs)
Set the minimum trim gap between pool trim checks.
|
DataSourceConfig |
setUrl(String url)
Set the connection URL.
|
DataSourceConfig |
setUsername(String username)
Set the database username.
|
DataSourceConfig |
setWaitTimeoutMillis(int waitTimeoutMillis)
Set the time in millis to wait for a connection before timing out once the
pool has reached its maximum size.
|
boolean |
useInitDatabase()
Return true if InitDatabase should be used (when the pool initialises and a connection can't be obtained).
|
public DataSourceConfig()
public DataSourceConfig copy()
public DataSourceConfig setDefaults(DataSourceConfig other)
public boolean isEmpty()
public DataSourceConfig setUrl(String url)
public String getUsername()
public DataSourceConfig setUsername(String username)
public String getPassword()
public DataSourceConfig setPassword(String password)
public DataSourceConfig setSchema(String schema)
public DataSourceConfig setDriver(String driver)
public int getIsolationLevel()
public DataSourceConfig setIsolationLevel(int isolationLevel)
public boolean isAutoCommit()
public DataSourceConfig setAutoCommit(boolean autoCommit)
public boolean isReadOnly()
public DataSourceConfig setReadOnly(boolean readOnly)
public int getMinConnections()
public DataSourceConfig setMinConnections(int minConnections)
public int getMaxConnections()
public DataSourceConfig setMaxConnections(int maxConnections)
public DataSourceAlert getAlert()
public DataSourceConfig setAlert(DataSourceAlert alert)
public DataSourcePoolListener getListener()
public DataSourceConfig setListener(DataSourcePoolListener listener)
public String getHeartbeatSql()
Note that if this is not set then it can get defaulted from the DatabasePlatform.
public DataSourceConfig 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 DataSourceConfig setHeartbeatFreqSecs(int heartbeatFreqSecs)
public int getHeartbeatTimeoutSeconds()
public DataSourceConfig setHeartbeatTimeoutSeconds(int heartbeatTimeoutSeconds)
public boolean isCaptureStackTrace()
This can be used to diagnose a suspected connection pool leak.
Obviously this has a performance overhead.
public DataSourceConfig setCaptureStackTrace(boolean captureStackTrace)
This can be used to diagnose a suspected connection pool leak.
Obviously this has a performance overhead.
public int getMaxStackTraceSize()
public DataSourceConfig setMaxStackTraceSize(int maxStackTraceSize)
public int getLeakTimeMinutes()
public DataSourceConfig setLeakTimeMinutes(int leakTimeMinutes)
public int getPstmtCacheSize()
public DataSourceConfig setPstmtCacheSize(int pstmtCacheSize)
public int getCstmtCacheSize()
public DataSourceConfig setCstmtCacheSize(int cstmtCacheSize)
public int getWaitTimeoutMillis()
public DataSourceConfig 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 DataSourceConfig setMaxAgeMinutes(int maxAgeMinutes)
public DataSourceConfig 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 DataSourceConfig setTrimPoolFreqSecs(int trimPoolFreqSecs)
public String getPoolListener()
public DataSourceConfig setPoolListener(String poolListener)
public boolean isOffline()
This is to support DDL generation etc without having a real database.
public boolean isFailOnStart()
This enables to initialize the Ebean-Server if the db-server is not yet up.
(DataSourceAlert.dataSourceUp(javax.sql.DataSource) is fired when DS gets up later.)
public DataSourceConfig setFailOnStart(boolean failOnStart)
public DataSourceConfig setOffline(boolean offline)
public Map<String,String> getCustomProperties()
public List<String> getInitSql()
public DataSourceConfig setInitSql(List<String> initSql)
public DataSourceConfig setCustomProperties(Map<String,String> customProperties)
public String getOwnerUsername()
public DataSourceConfig setOwnerUsername(String ownerUsername)
public String getOwnerPassword()
public DataSourceConfig setOwnerPassword(String ownerPassword)
public String getPlatform()
public DataSourceConfig setPlatform(String platform)
public InitDatabase getInitDatabase()
public DataSourceConfig setInitDatabase(InitDatabase initDatabase)
public DataSourceConfig setInitDatabaseForPlatform(String platform)
public boolean useInitDatabase()
public DataSourceConfig 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 © 2019. All rights reserved.