com.avaje.ebean.config
Class DataSourceConfig

java.lang.Object
  extended by com.avaje.ebean.config.DataSourceConfig

public class DataSourceConfig
extends Object

Used to config a DataSource when using the internal Ebean DataSource implementation.

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.


Constructor Summary
DataSourceConfig()
           
 
Method Summary
 int getCstmtCacheSize()
          Return the size of the CallableStatement cache (per connection).
 String getDriver()
          Return the database driver.
 String getHeartbeatSql()
          Return a SQL statement used to test the database is accessible.
 int getLeakTimeMinutes()
          Return the time in minutes after which a connection could be considered to have leaked.
 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).
 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)
          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 setDriver(String driver)
          Set the database driver.
 void setHeartbeatSql(String heartbeatSql)
          Set a SQL statement used to test the database is accessible.
 void setLeakTimeMinutes(int leakTimeMinutes)
          Set the time in minutes after which a connection could be considered to have leaked.
 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 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSourceConfig

public DataSourceConfig()
Method Detail

getUrl

public String getUrl()
Return the connection URL.


setUrl

public void setUrl(String url)
Set the connection URL.


getUsername

public String getUsername()
Return the database username.


setUsername

public void setUsername(String username)
Set the database username.


getPassword

public String getPassword()
Return the database password.


setPassword

public void setPassword(String password)
Set the database password.


getDriver

public String getDriver()
Return the database driver.


setDriver

public void setDriver(String driver)
Set the database driver.


getMinConnections

public int getMinConnections()
Return the minimum number of connections the pool should maintain.


setMinConnections

public void setMinConnections(int minConnections)
Set the minimum number of connections the pool should maintain.


getMaxConnections

public int getMaxConnections()
Return the maximum number of connections the pool can reach.


setMaxConnections

public void setMaxConnections(int maxConnections)
Set the maximum number of connections the pool can reach.


getHeartbeatSql

public String getHeartbeatSql()
Return a SQL statement used to test the database is accessible.

Note that if this is not set then it can get defaulted from the DatabasePlatform.


setHeartbeatSql

public void setHeartbeatSql(String heartbeatSql)
Set a SQL statement used to test the database is accessible.

Note that if this is not set then it can get defaulted from the DatabasePlatform.


isCaptureStackTrace

public boolean isCaptureStackTrace()
Return true if a stack trace should be captured when obtaining a connection from the pool.

This can be used to diagnose a suspected connection pool leak.

Obviously this has a performance overhead.


setCaptureStackTrace

public void setCaptureStackTrace(boolean captureStackTrace)
Set to true if a stack trace should be captured when obtaining a connection from the pool.

This can be used to diagnose a suspected connection pool leak.

Obviously this has a performance overhead.


getMaxStackTraceSize

public int getMaxStackTraceSize()
Return the max size for reporting stack traces on busy connections.


setMaxStackTraceSize

public void setMaxStackTraceSize(int maxStackTraceSize)
Set the max size for reporting stack traces on busy connections.


getLeakTimeMinutes

public int getLeakTimeMinutes()
Return the time in minutes after which a connection could be considered to have leaked.


setLeakTimeMinutes

public void setLeakTimeMinutes(int leakTimeMinutes)
Set the time in minutes after which a connection could be considered to have leaked.


getPstmtCacheSize

public int getPstmtCacheSize()
Return the size of the PreparedStatement cache (per connection).


setPstmtCacheSize

public void setPstmtCacheSize(int pstmtCacheSize)
Set the size of the PreparedStatement cache (per connection).


getCstmtCacheSize

public int getCstmtCacheSize()
Return the size of the CallableStatement cache (per connection).


setCstmtCacheSize

public void setCstmtCacheSize(int cstmtCacheSize)
Set the size of the CallableStatement cache (per connection).


getWaitTimeoutMillis

public int getWaitTimeoutMillis()
Return the time in millis to wait for a connection before timing out once the pool has reached its maximum size.


setWaitTimeoutMillis

public 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.


getMaxInactiveTimeSecs

public int getMaxInactiveTimeSecs()
Return the time in seconds a connection can be idle after which it can be trimmed from the pool.

This is so that the pool after a busy period can trend over time back towards the minimum connections.


setMaxInactiveTimeSecs

public void setMaxInactiveTimeSecs(int maxInactiveTimeSecs)
Set the time in seconds a connection can be idle after which it can be trimmed from the pool.

This is so that the pool after a busy period can trend over time back towards the minimum connections.


getPoolListener

public String getPoolListener()
Return the pool listener.


setPoolListener

public void setPoolListener(String poolListener)
Set a pool listener.


isOffline

public boolean isOffline()
Return true if the DataSource should be left offline.

This is to support DDL generation etc without having a real database.


setOffline

public void setOffline(boolean offline)
Set to true if the DataSource should be left 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.


loadSettings

public void loadSettings(String serverName)
Load the settings from ebean.properties.



Copyright © 2010. All Rights Reserved.