public class DataSourceConfig extends Object
If a DataSource instance is already defined via
ServerConfig.setDataSource(javax.sql.DataSource) or defined as JNDI
dataSource via ServerConfig.setDataSourceJndiName(String) then those
will used and not this DataSourceConfig.
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,String> |
customProperties |
| Constructor and Description |
|---|
DataSourceConfig() |
| Modifier and Type | Method and Description |
|---|---|
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.
|
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 |
getTransactionIsolationLevel(String level)
return the isolation level for a given string description.
|
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 |
isCaptureStackTrace()
Return true if a stack trace should be captured when obtaining a connection
from the pool.
|
boolean |
isOffline()
Return true if the DataSource should be left offline.
|
void |
loadSettings(String serverName) |
void |
loadSettingsCustomPrefix(String prefix,
GlobalProperties.PropertySource properties)
Load the settings from ebean.properties.
|
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 |
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 |
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 |
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 String getUrl()
public void setUrl(String url)
public String getUsername()
public void setUsername(String username)
public String getPassword()
public void setPassword(String password)
public String getDriver()
public void setDriver(String driver)
public int getIsolationLevel()
public void setIsolationLevel(int isolationLevel)
public int getMinConnections()
public void setMinConnections(int minConnections)
public int getMaxConnections()
public void setMaxConnections(int maxConnections)
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)
This is to support DDL generation etc without having a real database.
Note that you MUST specify the database platform name (oracle, postgres,
h2, mysql etc) using ServerConfig.setDatabasePlatformName(String)
when you do this.
public Map<String,String> getCustomProperties()
public void setCustomProperties(Map<String,String> customProperties)
customProperties - public void loadSettings(String serverName)
public void loadSettingsCustomPrefix(String prefix, GlobalProperties.PropertySource properties)
public int getTransactionIsolationLevel(String level)
Copyright © 2014. All Rights Reserved.