com.jolbox.bonecp
Class BoneCPConfig

java.lang.Object
  extended by com.jolbox.bonecp.BoneCPConfig
All Implemented Interfaces:
BoneCPConfigMBean, Serializable, Cloneable
Direct Known Subclasses:
BoneCPDataSource

public class BoneCPConfig
extends Object
implements BoneCPConfigMBean, Cloneable, Serializable

Configuration class.

Author:
wallacew
See Also:
Serialized Form

Constructor Summary
BoneCPConfig()
          Default constructor.
BoneCPConfig(InputStream xmlConfigFile, String sectionName)
          Initialise the configuration by loading an XML file containing the settings.
BoneCPConfig(Properties props)
          Creates a new config using the given properties.
BoneCPConfig(String sectionName)
          Initialize the configuration by loading bonecp-config.xml containing the settings.
 
Method Summary
 BoneCPConfig clone()
           
 int getAcquireIncrement()
          Gets the acquireIncrement property.
 int getAcquireRetryAttempts()
          After attempting to acquire a connection and failing, try to connect these many times before giving up.
 long getAcquireRetryDelay()
          Deprecated. Use getAcquireRetryDelayInMs() instead.
 long getAcquireRetryDelay(TimeUnit timeUnit)
          Returns the acquireRetryDelay setting with the specified granularity.
 long getAcquireRetryDelayInMs()
          Returns the number of ms to wait before attempting to obtain a connection again after a failure.
 ClassLoader getClassLoader()
          Returns the currently active classloader.
 long getCloseConnectionWatchTimeout()
          Deprecated. Use getCloseConnectionWatchTimeoutInMs() instead
 long getCloseConnectionWatchTimeout(TimeUnit timeUnit)
          Returns the closeConnectionWatchTimeout with the specified granularity.
 long getCloseConnectionWatchTimeoutInMs()
          Returns the no of ms to wait when close connection watch threads are enabled.
 String getConfigFile()
          Returns the configFile field.
 ConnectionHook getConnectionHook()
          Returns the connection hook class.
 String getConnectionHookClassName()
          Returns the connection hook class name as passed via the setter
 String getConnectionTestStatement()
          Gets connectionTestStatement
 long getConnectionTimeout()
          Deprecated. Use getConnectionTimeoutInMs() instead.
 long getConnectionTimeout(TimeUnit timeUnit)
          Returns the connectionTimeout with the specified granularity.
 long getConnectionTimeoutInMs()
          Returns the maximum time (in milliseconds) to wait before a call to getConnection is timed out.
 DataSource getDatasourceBean()
          Returns the bean being used to return a connection.
 Boolean getDefaultAutoCommit()
          Returns the defaultAutoCommit field.
 String getDefaultCatalog()
          Returns the defaultCatalog field.
 Boolean getDefaultReadOnly()
          Returns the defaultReadOnly field.
 String getDefaultTransactionIsolation()
          Returns the defaultTransactionIsolation field.
protected  int getDefaultTransactionIsolationValue()
          Returns the defaultTransactionIsolationValue field.
 Properties getDriverProperties()
          Returns the currently configured driver properties.
 long getIdleConnectionTestPeriod()
          Deprecated. Please use getIdleConnectionTestPeriodInMinutes() instead.
 long getIdleConnectionTestPeriod(TimeUnit timeUnit)
          Returns the idleConnectionTestPeriod with the specified granularity.
 long getIdleConnectionTestPeriodInMinutes()
          Gets the currently set idleConnectionTestPeriodInMinutes.
 long getIdleMaxAge()
          Deprecated. Use getIdleMaxAgeInMinutes() instead
 long getIdleMaxAge(TimeUnit timeUnit)
          Returns the idleMaxAge with the specified granularity.
 long getIdleMaxAgeInMinutes()
          Returns the idleMaxAge currently set.
 String getInitSQL()
          Returns the initSQL parameter.
 String getJdbcUrl()
          Gets the configured JDBC URL
 long getMaxConnectionAge()
          Deprecated. Please use getMaxConnectionAgeInSeconds() instead.
 long getMaxConnectionAge(TimeUnit timeUnit)
          Returns the maxConnectionAge with the specified granularity.
 long getMaxConnectionAgeInSeconds()
          Returns the maxConnectionAge field in seconds
 int getMaxConnectionsPerPartition()
          Gets the maximum number of connections that will be contained in every partition.
 int getMinConnectionsPerPartition()
          Gets the minimum number of connections that will be contained in every partition.
 int getPartitionCount()
          Gets the number of currently defined partitions.
 String getPassword()
          Gets password to use for connections
 int getPoolAvailabilityThreshold()
          Returns the pool watch connection threshold value.
 String getPoolName()
          Returns the name of the pool for JMX and thread names.
 int getPreparedStatementCacheSize()
          Deprecated. 
 int getPreparedStatementsCacheSize()
          Deprecated. 
 long getQueryExecuteTimeLimit()
          Deprecated. Use getQueryExecuteTimeLimitInMs() instead.
 long getQueryExecuteTimeLimit(TimeUnit timeUnit)
          Returns the queryExecuteTimeLimit setting with the specified granularity.
 long getQueryExecuteTimeLimitInMs()
          Return the query execute time limit.
 int getReleaseHelperThreads()
          Gets number of release-connection helper threads to create per partition.
 String getServiceOrder()
          Returns the serviceOrder field.
 int getStatementCacheSize()
          Deprecated. 
 int getStatementReleaseHelperThreads()
          Returns the statementHelperThreads field.
 int getStatementsCachedPerConnection()
          Deprecated. 
 int getStatementsCacheSize()
          Gets statementsCacheSize setting.
 String getUsername()
          Gets username to use for the connections.
 boolean hasSameConfiguration(BoneCPConfig that)
          Returns true if this instance has the same config as a given config.
 boolean isCloseConnectionWatch()
          Returns if BoneCP is configured to create a helper thread to watch over connection acquires that are never released (or released twice).
 boolean isDisableConnectionTracking()
          Returns true if connection tracking has been disabled.
 boolean isDisableJMX()
          Return true if JMX is disabled.
 boolean isExternalAuth()
          Returns the current externalAuth setting.
 boolean isLazyInit()
          Returns true if connection pool is to be initialized lazily.
 boolean isLogStatementsEnabled()
          Returns true if SQL logging is currently enabled, false otherwise.
 boolean isStatisticsEnabled()
          Returns the statisticsEnabled field.
 boolean isTransactionRecoveryEnabled()
          Returns true if the pool is configured to record all transaction activity and replay the transaction automatically in case of connection failures.
protected  Class<?> loadClass(String clazz)
          Loads the given class, respecting the given classloader.
protected  void loadProperties(String filename)
          Loads the given properties file using the classloader.
 void sanitize()
          Performs validation on the config object.
 void setAcquireIncrement(int acquireIncrement)
          Sets the acquireIncrement property.
 void setAcquireRetryAttempts(int acquireRetryAttempts)
          After attempting to acquire a connection and failing, try to connect these many times before giving up.
 void setAcquireRetryDelay(int acquireRetryDelayInMs)
          Deprecated. Use setAcquireRetryDelayInMs(long).
 void setAcquireRetryDelay(long acquireRetryDelay, TimeUnit timeUnit)
          Sets the number of ms to wait before attempting to obtain a connection again after a failure.
 void setAcquireRetryDelayInMs(long acquireRetryDelay)
          Sets the number of ms to wait before attempting to obtain a connection again after a failure.
 void setClassLoader(ClassLoader classLoader)
          Sets the classloader to use to load JDBC driver and hooks (set to null to use default).
 void setCloseConnectionWatch(boolean closeConnectionWatch)
          Instruct the pool to create a helper thread to watch over connection acquires that are never released (or released twice).
 void setCloseConnectionWatchTimeout(long closeConnectionWatchTimeout)
          Deprecated. Use setCloseConnectionWatchTimeoutInMs(long) instead
 void setCloseConnectionWatchTimeout(long closeConnectionWatchTimeout, TimeUnit timeUnit)
          Sets the time to wait when close connection watch threads are enabled.
 void setCloseConnectionWatchTimeoutInMs(long closeConnectionWatchTimeout)
          Sets the no of ms to wait when close connection watch threads are enabled.
 void setConfigFile(String configFile)
          Sets the configFile.
 void setConnectionHook(ConnectionHook connectionHook)
          Sets the connection hook.
 void setConnectionHookClassName(String connectionHookClassName)
          Sets the connection hook class name.
 void setConnectionTestStatement(String connectionTestStatement)
          Sets the connection test statement.
 void setConnectionTimeout(long connectionTimeout)
          Deprecated. Use setConnectionTimeoutInMs(long) instead.
 void setConnectionTimeout(long connectionTimeout, TimeUnit timeUnit)
          Sets the maximum time to wait before a call to getConnection is timed out.
 void setConnectionTimeoutInMs(long connectionTimeoutinMs)
          Sets the maximum time (in milliseconds) to wait before a call to getConnection is timed out.
 void setDatasourceBean(DataSource datasourceBean)
          If set, use datasourceBean.getConnection() to obtain a new connection instead of Driver.getConnection().
 void setDefaultAutoCommit(Boolean defaultAutoCommit)
          Sets the defaultAutoCommit setting for newly created connections.
 void setDefaultCatalog(String defaultCatalog)
          Sets the defaultCatalog setting for newly created connections.
 void setDefaultReadOnly(Boolean defaultReadOnly)
          Sets the defaultReadOnly setting for newly created connections.
 void setDefaultTransactionIsolation(String defaultTransactionIsolation)
          Sets the defaultTransactionIsolation.
protected  void setDefaultTransactionIsolationValue(int defaultTransactionIsolationValue)
          Sets the defaultTransactionIsolationValue.
 void setDisableConnectionTracking(boolean disableConnectionTracking)
          If set to true, the pool will not monitor connections for proper closure.
 void setDisableJMX(boolean disableJMX)
          Set to true to disable JMX.
 void setDriverProperties(Properties driverProperties)
          Sets properties that will be passed on to the driver.
 void setExternalAuth(boolean externalAuth)
          If set to true, no attempts at passing in a username/password will be attempted when trying to obtain a raw (driver) connection.
 void setIdleConnectionTestPeriod(long idleConnectionTestPeriod)
          Deprecated. Please use setIdleConnectionTestPeriodInMinutes(long) or setIdleConnectionTestPeriod(long, TimeUnit) instead
 void setIdleConnectionTestPeriod(long idleConnectionTestPeriod, TimeUnit timeUnit)
          Wrapper method for idleConnectionTestPeriod for easier programmatic access.
 void setIdleConnectionTestPeriodInMinutes(long idleConnectionTestPeriod)
          Sets the idleConnectionTestPeriod.
 void setIdleConnectionTestPeriodInSeconds(long idleConnectionTestPeriod)
          Sets the idleConnectionTestPeriod.
 void setIdleMaxAge(long idleMaxAge)
          Deprecated. Use setIdleMaxAgeInMinutes(long) or setIdleMaxAge(long, TimeUnit) instead.
 void setIdleMaxAge(long idleMaxAge, TimeUnit timeUnit)
          Sets Idle max age.
 void setIdleMaxAgeInMinutes(long idleMaxAge)
          Sets Idle max age (in min).
 void setIdleMaxAgeInSeconds(long idleMaxAge)
          Sets Idle max age (in seconds).
 void setInitSQL(String initSQL)
          Specifies an initial SQL statement that is run only when a connection is first created.
 void setJdbcUrl(String jdbcUrl)
          Sets the JDBC connection URL.
 void setLazyInit(boolean lazyInit)
          Set to true to force the connection pool to obtain the initial connections lazily.
 void setLogStatementsEnabled(boolean logStatementsEnabled)
          If enabled, log SQL statements being executed.
 void setMaxConnectionAge(long maxConnectionAgeInSeconds)
          Deprecated. Please use {setMaxConnectionAgeInSeconds(long) instead.
 void setMaxConnectionAge(long maxConnectionAge, TimeUnit timeUnit)
          Sets the maxConnectionAge.
 void setMaxConnectionAgeInSeconds(long maxConnectionAgeInSeconds)
          Sets the maxConnectionAge in seconds.
 void setMaxConnectionsPerPartition(int maxConnectionsPerPartition)
          Sets the maximum number of connections that will be contained in every partition.
 void setMinConnectionsPerPartition(int minConnectionsPerPartition)
          Sets the minimum number of connections that will be contained in every partition.
 void setPartitionCount(int partitionCount)
          Sets number of partitions to use.
 void setPassword(String password)
          Sets password to use for connections.
 void setPoolAvailabilityThreshold(int poolAvailabilityThreshold)
          Sets the Pool Watch thread threshold.
 void setPoolName(String poolName)
          Sets the name of the pool for JMX and thread names.
 void setPreparedStatementsCacheSize(int preparedStatementsCacheSize)
          Deprecated. 
 void setProperties(Properties props)
          Sets the properties by reading off entries in the given parameter (where each key is equivalent to the field name)
 void setQueryExecuteTimeLimit(int queryExecuteTimeLimit)
          Deprecated. Use setQueryExecuteTimeLimitInMs(long) instead.
 void setQueryExecuteTimeLimit(long queryExecuteTimeLimit, TimeUnit timeUnit)
          Queries taking longer than this limit to execute are logged.
 void setQueryExecuteTimeLimitInMs(long queryExecuteTimeLimit)
          Queries taking longer than this limit to execute are logged.
 void setReleaseHelperThreads(int releaseHelperThreads)
          Sets number of helper threads to create that will handle releasing a connection.
 void setServiceOrder(String serviceOrder)
          Sets the queue serviceOrder.
 void setStatementCacheSize(int statementsCacheSize)
          Deprecated. 
 void setStatementReleaseHelperThreads(int statementReleaseHelperThreads)
          Sets number of statement helper threads to create that will handle releasing a statement.
 void setStatementsCachedPerConnection(int statementsCachedPerConnection)
          Deprecated. 
 void setStatementsCacheSize(int statementsCacheSize)
          Sets statementsCacheSize setting.
 void setStatisticsEnabled(boolean statisticsEnabled)
          If set to true, keep track of some more statistics for exposure via JMX.
 void setTransactionRecoveryEnabled(boolean transactionRecoveryEnabled)
          Set to true to enable recording of all transaction activity and replay the transaction automatically in case of a connection failure.
 void setUsername(String username)
          Sets username to use for connections.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BoneCPConfig

public BoneCPConfig()
Default constructor. Attempts to fill settings in this order: 1. bonecp-default-config.xml file, usually found in the pool jar 2. bonecp-config.xml file, usually found in your application's classpath 3. Other hardcoded defaults in BoneCPConfig class.


BoneCPConfig

public BoneCPConfig(Properties props)
             throws Exception
Creates a new config using the given properties.

Parameters:
props - properties to set.
Throws:
Exception - on error

BoneCPConfig

public BoneCPConfig(String sectionName)
             throws Exception
Initialize the configuration by loading bonecp-config.xml containing the settings.

Parameters:
sectionName - section to load
Throws:
Exception - on parse errors

BoneCPConfig

public BoneCPConfig(InputStream xmlConfigFile,
                    String sectionName)
             throws Exception
Initialise the configuration by loading an XML file containing the settings.

Parameters:
xmlConfigFile - file to load
sectionName - section to load
Throws:
Exception
Method Detail

getPoolName

public String getPoolName()
Returns the name of the pool for JMX and thread names.

Specified by:
getPoolName in interface BoneCPConfigMBean
Returns:
a pool name.

setPoolName

public void setPoolName(String poolName)
Sets the name of the pool for JMX and thread names.

Parameters:
poolName - to set.

getMinConnectionsPerPartition

public int getMinConnectionsPerPartition()
Gets the minimum number of connections that will be contained in every partition.

Specified by:
getMinConnectionsPerPartition in interface BoneCPConfigMBean
Returns:
minConnectionsPerPartition
See Also:
BoneCPConfigMBean.getMinConnectionsPerPartition()

setMinConnectionsPerPartition

public void setMinConnectionsPerPartition(int minConnectionsPerPartition)
Sets the minimum number of connections that will be contained in every partition.

Parameters:
minConnectionsPerPartition - number of connections

getMaxConnectionsPerPartition

public int getMaxConnectionsPerPartition()
Gets the maximum number of connections that will be contained in every partition.

Specified by:
getMaxConnectionsPerPartition in interface BoneCPConfigMBean
Returns:
maxConnectionsPerPartition
See Also:
BoneCPConfigMBean.getMaxConnectionsPerPartition()

setMaxConnectionsPerPartition

public void setMaxConnectionsPerPartition(int maxConnectionsPerPartition)
Sets the maximum number of connections that will be contained in every partition. Setting this to 5 with 3 partitions means you will have 15 unique connections to the database. Note that the connection pool will not create all these connections in one go but rather start off with minConnectionsPerPartition and gradually increase connections as required.

Parameters:
maxConnectionsPerPartition - number of connections.

getAcquireIncrement

public int getAcquireIncrement()
Gets the acquireIncrement property. Gets the current value of the number of connections to add every time the number of available connections is about to run out (up to the maxConnectionsPerPartition).

Specified by:
getAcquireIncrement in interface BoneCPConfigMBean
Returns:
acquireIncrement number of connections to add.
See Also:
BoneCPConfigMBean.getAcquireIncrement()

setAcquireIncrement

public void setAcquireIncrement(int acquireIncrement)
Sets the acquireIncrement property. When the available connections are about to run out, BoneCP will dynamically create new ones in batches. This property controls how many new connections to create in one go (up to a maximum of maxConnectionsPerPartition).

Note: This is a per partition setting.

Parameters:
acquireIncrement - value to set.

getPartitionCount

public int getPartitionCount()
Gets the number of currently defined partitions.

Specified by:
getPartitionCount in interface BoneCPConfigMBean
Returns:
partitionCount
See Also:
BoneCPConfigMBean.getPartitionCount()

setPartitionCount

public void setPartitionCount(int partitionCount)
Sets number of partitions to use. In order to reduce lock contention and thus improve performance, each incoming connection request picks off a connection from a pool that has thread-affinity, i.e. pool[threadId % partition_count]. The higher this number, the better your performance will be for the case when you have plenty of short-lived threads. Beyond a certain threshold, maintenance of these pools will start to have a negative effect on performance (and only for the case when connections on a partition start running out).

Default: 1, minimum: 1, recommended: 2-4 (but very app specific)

Parameters:
partitionCount - to set

getJdbcUrl

public String getJdbcUrl()
Gets the configured JDBC URL

Specified by:
getJdbcUrl in interface BoneCPConfigMBean
Returns:
jdbcUrl
See Also:
BoneCPConfigMBean.getJdbcUrl()

setJdbcUrl

public void setJdbcUrl(String jdbcUrl)
Sets the JDBC connection URL.

Parameters:
jdbcUrl - to set

getUsername

public String getUsername()
Gets username to use for the connections.

Specified by:
getUsername in interface BoneCPConfigMBean
Returns:
username
See Also:
BoneCPConfigMBean.getUsername()

setUsername

public void setUsername(String username)
Sets username to use for connections.

Parameters:
username - to set

getPassword

public String getPassword()
Gets password to use for connections

Returns:
password

setPassword

public void setPassword(String password)
Sets password to use for connections.

Parameters:
password - to set.

getIdleConnectionTestPeriod

@Deprecated
public long getIdleConnectionTestPeriod()
Deprecated. Please use getIdleConnectionTestPeriodInMinutes() instead.

Deprecated.

Returns:
idleConnectionTest

setIdleConnectionTestPeriod

@Deprecated
public void setIdleConnectionTestPeriod(long idleConnectionTestPeriod)
Deprecated. Please use setIdleConnectionTestPeriodInMinutes(long) or setIdleConnectionTestPeriod(long, TimeUnit) instead

Sets the idleConnectionTestPeriod in minutes

Parameters:
idleConnectionTestPeriod - to set in minutes

getIdleConnectionTestPeriodInMinutes

public long getIdleConnectionTestPeriodInMinutes()
Gets the currently set idleConnectionTestPeriodInMinutes.

Specified by:
getIdleConnectionTestPeriodInMinutes in interface BoneCPConfigMBean
Returns:
idleConnectionTestPeriod
See Also:
BoneCPConfigMBean.getIdleConnectionTestPeriodInMinutes()

getIdleConnectionTestPeriod

public long getIdleConnectionTestPeriod(TimeUnit timeUnit)
Returns the idleConnectionTestPeriod with the specified granularity.

Parameters:
timeUnit - time granularity
Returns:
Idle Connection test period

setIdleConnectionTestPeriodInMinutes

public void setIdleConnectionTestPeriodInMinutes(long idleConnectionTestPeriod)
Sets the idleConnectionTestPeriod. This sets the time (in minutes), for a connection to remain idle before sending a test query to the DB. This is useful to prevent a DB from timing out connections on its end. Do not use aggressive values here!

Default: 240 min, set to 0 to disable

Parameters:
idleConnectionTestPeriod - to set

setIdleConnectionTestPeriodInSeconds

public void setIdleConnectionTestPeriodInSeconds(long idleConnectionTestPeriod)
Sets the idleConnectionTestPeriod. This sets the time (in seconds), for a connection to remain idle before sending a test query to the DB. This is useful to prevent a DB from timing out connections on its end. Do not use aggressive values here!

Default: 240 min, set to 0 to disable

Parameters:
idleConnectionTestPeriod - to set

setIdleConnectionTestPeriod

public void setIdleConnectionTestPeriod(long idleConnectionTestPeriod,
                                        TimeUnit timeUnit)
Wrapper method for idleConnectionTestPeriod for easier programmatic access.

Parameters:
idleConnectionTestPeriod - time for a connection to remain idle before sending a test query to the DB.
timeUnit - Time granularity of given parameter.

getIdleMaxAge

@Deprecated
public long getIdleMaxAge()
Deprecated. Use getIdleMaxAgeInMinutes() instead

Deprecated.

Returns:
idleMaxAge in minutes

getIdleMaxAge

public long getIdleMaxAge(TimeUnit timeUnit)
Returns the idleMaxAge with the specified granularity.

Parameters:
timeUnit - time granularity
Returns:
idleMaxAge value

getIdleMaxAgeInMinutes

public long getIdleMaxAgeInMinutes()
Returns the idleMaxAge currently set.

Specified by:
getIdleMaxAgeInMinutes in interface BoneCPConfigMBean
Returns:
idleMaxAge in minutes

setIdleMaxAge

@Deprecated
public void setIdleMaxAge(long idleMaxAge)
Deprecated. Use setIdleMaxAgeInMinutes(long) or setIdleMaxAge(long, TimeUnit) instead.

Deprecated.

Parameters:
idleMaxAge - to set

setIdleMaxAgeInMinutes

public void setIdleMaxAgeInMinutes(long idleMaxAge)
Sets Idle max age (in min). The time (in minutes), for a connection to remain unused before it is closed off. Do not use aggressive values here!

Default: 60 minutes, set to 0 to disable.

Parameters:
idleMaxAge - to set

setIdleMaxAgeInSeconds

public void setIdleMaxAgeInSeconds(long idleMaxAge)
Sets Idle max age (in seconds). The time (in seconds), for a connection to remain unused before it is closed off. Do not use aggressive values here!

Default: 60 minutes, set to 0 to disable.

Parameters:
idleMaxAge - to set

setIdleMaxAge

public void setIdleMaxAge(long idleMaxAge,
                          TimeUnit timeUnit)
Sets Idle max age. The time, for a connection to remain unused before it is closed off. Do not use aggressive values here!

Parameters:
idleMaxAge - time after which a connection is closed off
timeUnit - idleMaxAge time granularity.

getConnectionTestStatement

public String getConnectionTestStatement()
Gets connectionTestStatement

Specified by:
getConnectionTestStatement in interface BoneCPConfigMBean
Returns:
connectionTestStatement
See Also:
BoneCPConfigMBean.getConnectionTestStatement()

setConnectionTestStatement

public void setConnectionTestStatement(String connectionTestStatement)
Sets the connection test statement. The query to send to the DB to maintain keep-alives and test for dead connections. This is database specific and should be set to a query that consumes the minimal amount of load on the server. Examples: MySQL: "/* ping *\/ SELECT 1", PostgreSQL: "SELECT NOW()". If you do not set this, then BoneCP will issue a metadata request instead that should work on all databases but is probably slower. (Note: In MySQL, prefixing the statement by /* ping *\/ makes the driver issue 1 fast packet instead. See http://blogs.sun.com/SDNChannel/entry/mysql_tips_for_java_developers )

Default: Use metadata request

Parameters:
connectionTestStatement - to set.

getPreparedStatementsCacheSize

@Deprecated
public int getPreparedStatementsCacheSize()
Deprecated. 

Deprecated. Use getStatementsCacheSize() instead

Returns:
statementsCacheSize

getPreparedStatementCacheSize

@Deprecated
public int getPreparedStatementCacheSize()
Deprecated. 

Deprecated. Use getStatementsCacheSize() instead

Returns:
statementsCacheSize

setPreparedStatementsCacheSize

@Deprecated
public void setPreparedStatementsCacheSize(int preparedStatementsCacheSize)
Deprecated. 

Deprecated. Use setStatementsCacheSize() instead.

Parameters:
preparedStatementsCacheSize - to set.

setStatementsCacheSize

public void setStatementsCacheSize(int statementsCacheSize)
Sets statementsCacheSize setting. The number of statements to cache.

Parameters:
statementsCacheSize - to set.

getStatementsCacheSize

public int getStatementsCacheSize()
Gets statementsCacheSize setting.

Specified by:
getStatementsCacheSize in interface BoneCPConfigMBean
Returns:
statementsCacheSize
See Also:
BoneCPConfigMBean.getStatementsCacheSize()

setStatementCacheSize

@Deprecated
public void setStatementCacheSize(int statementsCacheSize)
Deprecated. 

Deprecated. Use set statementCacheSize instead. The number of statements to cache.

Parameters:
statementsCacheSize - to set.

getStatementCacheSize

@Deprecated
public int getStatementCacheSize()
Deprecated. 

Deprecated. Use getStatementsCacheSize instead

Returns:
no of cache size.

getReleaseHelperThreads

public int getReleaseHelperThreads()
Gets number of release-connection helper threads to create per partition.

Specified by:
getReleaseHelperThreads in interface BoneCPConfigMBean
Returns:
number of threads
See Also:
BoneCPConfigMBean.getReleaseHelperThreads()

setReleaseHelperThreads

public void setReleaseHelperThreads(int releaseHelperThreads)
Sets number of helper threads to create that will handle releasing a connection. When this value is set to zero, the application thread is blocked until the pool is able to perform all the necessary cleanup to recycle the connection and make it available for another thread. When a non-zero value is set, the pool will create threads that will take care of recycling a connection when it is closed (the application dumps the connection into a temporary queue to be processed asychronously to the application via the release helper threads). Useful when your application is doing lots of work on each connection (i.e. perform an SQL query, do lots of non-DB stuff and perform another query), otherwise will probably slow things down.

Parameters:
releaseHelperThreads - no to release

getStatementsCachedPerConnection

@Deprecated
public int getStatementsCachedPerConnection()
Deprecated. 

Gets no of statements cached per connection.

Specified by:
getStatementsCachedPerConnection in interface BoneCPConfigMBean
Returns:
no of statements cached per connection.
See Also:
BoneCPConfigMBean.getStatementsCachedPerConnection()

setStatementsCachedPerConnection

@Deprecated
public void setStatementsCachedPerConnection(int statementsCachedPerConnection)
Deprecated. 

DEPRECATED. No longer necessary to call at all. Sets no of statements cached per connection. The number of prepared statements to cache per connection. This is usually only useful if you attempt to prepare the same prepared statement string in the same connection (usually due to a wrong design condition).

Parameters:
statementsCachedPerConnection - to set

getConnectionHook

public ConnectionHook getConnectionHook()
Returns the connection hook class.

Specified by:
getConnectionHook in interface BoneCPConfigMBean
Returns:
the connectionHook
See Also:
BoneCPConfigMBean.getConnectionHook()

setConnectionHook

public void setConnectionHook(ConnectionHook connectionHook)
Sets the connection hook. Fully qualified class name that implements the ConnectionHook interface (or extends AbstractConnectionHook). BoneCP will callback the specified class according to the connection state (onAcquire, onCheckIn, onCheckout, onDestroy).

Parameters:
connectionHook - the connectionHook to set

getInitSQL

public String getInitSQL()
Returns the initSQL parameter.

Specified by:
getInitSQL in interface BoneCPConfigMBean
Returns:
the initSQL
See Also:
BoneCPConfigMBean.getInitSQL()

setInitSQL

public void setInitSQL(String initSQL)
Specifies an initial SQL statement that is run only when a connection is first created.

Parameters:
initSQL - the initSQL to set

isCloseConnectionWatch

public boolean isCloseConnectionWatch()
Returns if BoneCP is configured to create a helper thread to watch over connection acquires that are never released (or released twice). FOR DEBUG PURPOSES ONLY.

Returns:
the current closeConnectionWatch setting.

setCloseConnectionWatch

public void setCloseConnectionWatch(boolean closeConnectionWatch)
Instruct the pool to create a helper thread to watch over connection acquires that are never released (or released twice). This is for debugging purposes only and will create a new thread for each call to getConnection(). Enabling this option will have a big negative impact on pool performance.

Parameters:
closeConnectionWatch - set to true to enable thread monitoring.

isLogStatementsEnabled

public boolean isLogStatementsEnabled()
Returns true if SQL logging is currently enabled, false otherwise.

Specified by:
isLogStatementsEnabled in interface BoneCPConfigMBean
Returns:
the logStatementsEnabled status

setLogStatementsEnabled

public void setLogStatementsEnabled(boolean logStatementsEnabled)
If enabled, log SQL statements being executed.

Parameters:
logStatementsEnabled - the logStatementsEnabled to set

getAcquireRetryDelay

@Deprecated
public long getAcquireRetryDelay()
Deprecated. Use getAcquireRetryDelayInMs() instead.

Deprecated.

Returns:
the acquireRetryDelay

setAcquireRetryDelay

@Deprecated
public void setAcquireRetryDelay(int acquireRetryDelayInMs)
Deprecated. Use setAcquireRetryDelayInMs(long).

Deprecated.

Parameters:
acquireRetryDelayInMs - the acquireRetryDelay to set

getAcquireRetryDelayInMs

public long getAcquireRetryDelayInMs()
Returns the number of ms to wait before attempting to obtain a connection again after a failure. Default: 7000.

Specified by:
getAcquireRetryDelayInMs in interface BoneCPConfigMBean
Returns:
the acquireRetryDelay

getAcquireRetryDelay

public long getAcquireRetryDelay(TimeUnit timeUnit)
Returns the acquireRetryDelay setting with the specified granularity.

Parameters:
timeUnit - time granularity
Returns:
acquireRetryDelay

setAcquireRetryDelayInMs

public void setAcquireRetryDelayInMs(long acquireRetryDelay)
Sets the number of ms to wait before attempting to obtain a connection again after a failure.

Parameters:
acquireRetryDelay - the acquireRetryDelay to set

setAcquireRetryDelay

public void setAcquireRetryDelay(long acquireRetryDelay,
                                 TimeUnit timeUnit)
Sets the number of ms to wait before attempting to obtain a connection again after a failure.

Parameters:
acquireRetryDelay - the acquireRetryDelay to set
timeUnit - time granularity

isLazyInit

public boolean isLazyInit()
Returns true if connection pool is to be initialized lazily.

Specified by:
isLazyInit in interface BoneCPConfigMBean
Returns:
lazyInit setting

setLazyInit

public void setLazyInit(boolean lazyInit)
Set to true to force the connection pool to obtain the initial connections lazily.

Parameters:
lazyInit - the lazyInit setting to set

isTransactionRecoveryEnabled

public boolean isTransactionRecoveryEnabled()
Returns true if the pool is configured to record all transaction activity and replay the transaction automatically in case of connection failures.

Specified by:
isTransactionRecoveryEnabled in interface BoneCPConfigMBean
Returns:
the transactionRecoveryEnabled status

setTransactionRecoveryEnabled

public void setTransactionRecoveryEnabled(boolean transactionRecoveryEnabled)
Set to true to enable recording of all transaction activity and replay the transaction automatically in case of a connection failure.

Parameters:
transactionRecoveryEnabled - the transactionRecoveryEnabled status to set

getAcquireRetryAttempts

public int getAcquireRetryAttempts()
After attempting to acquire a connection and failing, try to connect these many times before giving up. Default 5.

Specified by:
getAcquireRetryAttempts in interface BoneCPConfigMBean
Returns:
the acquireRetryAttempts value

setAcquireRetryAttempts

public void setAcquireRetryAttempts(int acquireRetryAttempts)
After attempting to acquire a connection and failing, try to connect these many times before giving up. Default 5.

Parameters:
acquireRetryAttempts - the acquireRetryAttempts to set

setConnectionHookClassName

public void setConnectionHookClassName(String connectionHookClassName)
Sets the connection hook class name. Consider using setConnectionHook() instead.

Parameters:
connectionHookClassName - the connectionHook class name to set

getConnectionHookClassName

public String getConnectionHookClassName()
Returns the connection hook class name as passed via the setter

Specified by:
getConnectionHookClassName in interface BoneCPConfigMBean
Returns:
the connectionHookClassName.

isDisableJMX

public boolean isDisableJMX()
Return true if JMX is disabled.

Specified by:
isDisableJMX in interface BoneCPConfigMBean
Returns:
the disableJMX.

setDisableJMX

public void setDisableJMX(boolean disableJMX)
Set to true to disable JMX.

Parameters:
disableJMX - the disableJMX to set

getDatasourceBean

public DataSource getDatasourceBean()
Returns the bean being used to return a connection.

Returns:
the datasourceBean that was set.

setDatasourceBean

public void setDatasourceBean(DataSource datasourceBean)
If set, use datasourceBean.getConnection() to obtain a new connection instead of Driver.getConnection().

Parameters:
datasourceBean - the datasourceBean to set

getQueryExecuteTimeLimit

@Deprecated
public long getQueryExecuteTimeLimit()
Deprecated. Use getQueryExecuteTimeLimitInMs() instead.

Deprecated.

Returns:
the queryTimeLimit

setQueryExecuteTimeLimit

@Deprecated
public void setQueryExecuteTimeLimit(int queryExecuteTimeLimit)
Deprecated. Use setQueryExecuteTimeLimitInMs(long) instead.

Queries taking longer than this limit to execute are logged.

Parameters:
queryExecuteTimeLimit - the limit to set in milliseconds.

getQueryExecuteTimeLimitInMs

public long getQueryExecuteTimeLimitInMs()
Return the query execute time limit.

Specified by:
getQueryExecuteTimeLimitInMs in interface BoneCPConfigMBean
Returns:
the queryTimeLimit

getQueryExecuteTimeLimit

public long getQueryExecuteTimeLimit(TimeUnit timeUnit)
Returns the queryExecuteTimeLimit setting with the specified granularity.

Parameters:
timeUnit - time granularity
Returns:
queryExecuteTimeLimit period

setQueryExecuteTimeLimitInMs

public void setQueryExecuteTimeLimitInMs(long queryExecuteTimeLimit)
Queries taking longer than this limit to execute are logged.

Parameters:
queryExecuteTimeLimit - the limit to set in milliseconds.

setQueryExecuteTimeLimit

public void setQueryExecuteTimeLimit(long queryExecuteTimeLimit,
                                     TimeUnit timeUnit)
Queries taking longer than this limit to execute are logged.

Parameters:
queryExecuteTimeLimit - the limit to set in milliseconds.
timeUnit -

getPoolAvailabilityThreshold

public int getPoolAvailabilityThreshold()
Returns the pool watch connection threshold value.

Specified by:
getPoolAvailabilityThreshold in interface BoneCPConfigMBean
Returns:
the poolAvailabilityThreshold currently set.

setPoolAvailabilityThreshold

public void setPoolAvailabilityThreshold(int poolAvailabilityThreshold)
Sets the Pool Watch thread threshold. The pool watch thread attempts to maintain a number of connections always available (between minConnections and maxConnections). This value sets the percentage value to maintain. For example, setting it to 20 means that if the following condition holds: Free Connections / MaxConnections < poolAvailabilityThreshold new connections will be created. In other words, it tries to keep at least 20% of the pool full of connections. Setting the value to zero will make the pool create new connections when it needs them but it also means your application may have to wait for new connections to be obtained at times. Default: 20.

Parameters:
poolAvailabilityThreshold - the poolAvailabilityThreshold to set

isDisableConnectionTracking

public boolean isDisableConnectionTracking()
Returns true if connection tracking has been disabled.

Specified by:
isDisableConnectionTracking in interface BoneCPConfigMBean
Returns:
the disableConnectionTracking

setDisableConnectionTracking

public void setDisableConnectionTracking(boolean disableConnectionTracking)
If set to true, the pool will not monitor connections for proper closure. Enable this option if you only ever obtain your connections via a mechanism that is guaranteed to release the connection back to the pool (eg Spring's jdbcTemplate, some kind of transaction manager, etc).

Parameters:
disableConnectionTracking - set to true to disable. Default: false.

getConnectionTimeout

@Deprecated
public long getConnectionTimeout()
Deprecated. Use getConnectionTimeoutInMs() instead.

Deprecated.

Returns:
the connectionTimeout

setConnectionTimeout

@Deprecated
public void setConnectionTimeout(long connectionTimeout)
Deprecated. Use setConnectionTimeoutInMs(long) instead.

Deprecated.

Parameters:
connectionTimeout - the connectionTimeout to set

getConnectionTimeoutInMs

public long getConnectionTimeoutInMs()
Returns the maximum time (in milliseconds) to wait before a call to getConnection is timed out.

Specified by:
getConnectionTimeoutInMs in interface BoneCPConfigMBean
Returns:
the connectionTimeout

getConnectionTimeout

public long getConnectionTimeout(TimeUnit timeUnit)
Returns the connectionTimeout with the specified granularity.

Parameters:
timeUnit - time granularity
Returns:
connectionTimeout period

setConnectionTimeoutInMs

public void setConnectionTimeoutInMs(long connectionTimeoutinMs)
Sets the maximum time (in milliseconds) to wait before a call to getConnection is timed out. Setting this to zero is similar to setting it to Long.MAX_VALUE Default: 0 ( = wait forever )

Parameters:
connectionTimeoutinMs - the connectionTimeout to set

setConnectionTimeout

public void setConnectionTimeout(long connectionTimeout,
                                 TimeUnit timeUnit)
Sets the maximum time to wait before a call to getConnection is timed out. Setting this to zero is similar to setting it to Long.MAX_VALUE

Parameters:
connectionTimeout -
timeUnit - the unit of the connectionTimeout argument

getDriverProperties

public Properties getDriverProperties()
Returns the currently configured driver properties.

Returns:
the driverProperties handle

setDriverProperties

public void setDriverProperties(Properties driverProperties)
Sets properties that will be passed on to the driver. The properties handle should contain a list of arbitrary string tag/value pairs as connection arguments; normally at least a "user" and "password" property should be included. Failure to include the user or password properties will make the pool copy the values given in config.setUsername(..) and config.setPassword(..). Note that the pool will make a copy of these properties so as not to risk attempting to create a connection later on with different settings.

Parameters:
driverProperties - the driverProperties to set

getCloseConnectionWatchTimeout

@Deprecated
public long getCloseConnectionWatchTimeout()
Deprecated. Use getCloseConnectionWatchTimeoutInMs() instead

Deprecated.

Returns:
the watchTimeout currently set.

setCloseConnectionWatchTimeout

@Deprecated
public void setCloseConnectionWatchTimeout(long closeConnectionWatchTimeout)
Deprecated. Use setCloseConnectionWatchTimeoutInMs(long) instead

Deprecated.

Parameters:
closeConnectionWatchTimeout - the watchTimeout to set

getCloseConnectionWatchTimeoutInMs

public long getCloseConnectionWatchTimeoutInMs()
Returns the no of ms to wait when close connection watch threads are enabled. 0 = wait forever.

Specified by:
getCloseConnectionWatchTimeoutInMs in interface BoneCPConfigMBean
Returns:
the watchTimeout currently set.

getCloseConnectionWatchTimeout

public long getCloseConnectionWatchTimeout(TimeUnit timeUnit)
Returns the closeConnectionWatchTimeout with the specified granularity.

Parameters:
timeUnit - time granularity
Returns:
closeConnectionWatchTimeout period

setCloseConnectionWatchTimeoutInMs

public void setCloseConnectionWatchTimeoutInMs(long closeConnectionWatchTimeout)
Sets the no of ms to wait when close connection watch threads are enabled. 0 = wait forever.

Parameters:
closeConnectionWatchTimeout - the watchTimeout to set

setCloseConnectionWatchTimeout

public void setCloseConnectionWatchTimeout(long closeConnectionWatchTimeout,
                                           TimeUnit timeUnit)
Sets the time to wait when close connection watch threads are enabled. 0 = wait forever.

Parameters:
closeConnectionWatchTimeout - the watchTimeout to set
timeUnit - Time granularity

getStatementReleaseHelperThreads

public int getStatementReleaseHelperThreads()
Returns the statementHelperThreads field.

Specified by:
getStatementReleaseHelperThreads in interface BoneCPConfigMBean
Returns:
statementHelperThreads

setStatementReleaseHelperThreads

public void setStatementReleaseHelperThreads(int statementReleaseHelperThreads)
Sets number of statement helper threads to create that will handle releasing a statement. When this value is set to zero, the application thread is blocked until the pool and JDBC driver are able to close off the statement. When a non-zero value is set, the pool will create threads that will take care of closing off the statement asychronously to the application via the release helper threads). Useful when your application is opening up lots of statements otherwise will probably slow things down.

Parameters:
statementReleaseHelperThreads - no to release

getMaxConnectionAge

@Deprecated
public long getMaxConnectionAge()
Deprecated. Please use getMaxConnectionAgeInSeconds() instead.

Deprecated. Please use getMaxConnectionAgeInSeconds() instead.

Returns:
maxConnectionAge

getMaxConnectionAgeInSeconds

public long getMaxConnectionAgeInSeconds()
Returns the maxConnectionAge field in seconds

Specified by:
getMaxConnectionAgeInSeconds in interface BoneCPConfigMBean
Returns:
maxConnectionAge

getMaxConnectionAge

public long getMaxConnectionAge(TimeUnit timeUnit)
Returns the maxConnectionAge with the specified granularity.

Parameters:
timeUnit - time granularity
Returns:
maxConnectionAge period

setMaxConnectionAge

@Deprecated
public void setMaxConnectionAge(long maxConnectionAgeInSeconds)
Deprecated. Please use {setMaxConnectionAgeInSeconds(long) instead.

Deprecated. Use {setMaxConnectionAgeInSeconds(long) instead.

Parameters:
maxConnectionAgeInSeconds - the maxConnectionAge to set

setMaxConnectionAgeInSeconds

public void setMaxConnectionAgeInSeconds(long maxConnectionAgeInSeconds)
Sets the maxConnectionAge in seconds. Any connections older than this setting will be closed off whether it is idle or not. Connections currently in use will not be affected until they are returned to the pool.

Parameters:
maxConnectionAgeInSeconds - the maxConnectionAge to set

setMaxConnectionAge

public void setMaxConnectionAge(long maxConnectionAge,
                                TimeUnit timeUnit)
Sets the maxConnectionAge. Any connections older than this setting will be closed off whether it is idle or not. Connections currently in use will not be affected until they are returned to the pool.

Parameters:
maxConnectionAge - the maxConnectionAge to set.
timeUnit - the unit of the maxConnectionAge argument.

getConfigFile

public String getConfigFile()
Returns the configFile field.

Specified by:
getConfigFile in interface BoneCPConfigMBean
Returns:
configFile

setConfigFile

public void setConfigFile(String configFile)
Sets the configFile. If configured, this will cause the pool to initialise using the config file in the same way as if calling new BoneCPConfig(filename).

Parameters:
configFile - the configFile to set

getServiceOrder

public String getServiceOrder()
Returns the serviceOrder field.

Specified by:
getServiceOrder in interface BoneCPConfigMBean
Returns:
serviceOrder

setServiceOrder

public void setServiceOrder(String serviceOrder)
Sets the queue serviceOrder. Values currently understood are FIFO and LIFO.

Parameters:
serviceOrder - the serviceOrder to set

isStatisticsEnabled

public boolean isStatisticsEnabled()
Returns the statisticsEnabled field.

Specified by:
isStatisticsEnabled in interface BoneCPConfigMBean
Returns:
statisticsEnabled

setStatisticsEnabled

public void setStatisticsEnabled(boolean statisticsEnabled)
If set to true, keep track of some more statistics for exposure via JMX. Will slow down the pool operation.

Parameters:
statisticsEnabled - set to true to enable

getDefaultAutoCommit

public Boolean getDefaultAutoCommit()
Returns the defaultAutoCommit field.

Returns:
defaultAutoCommit

setDefaultAutoCommit

public void setDefaultAutoCommit(Boolean defaultAutoCommit)
Sets the defaultAutoCommit setting for newly created connections. If not set, use driver default.

Parameters:
defaultAutoCommit - the defaultAutoCommit to set

getDefaultReadOnly

public Boolean getDefaultReadOnly()
Returns the defaultReadOnly field.

Returns:
defaultReadOnly

setDefaultReadOnly

public void setDefaultReadOnly(Boolean defaultReadOnly)
Sets the defaultReadOnly setting for newly created connections. If not set, use driver default.

Parameters:
defaultReadOnly - the defaultReadOnly to set

getDefaultCatalog

public String getDefaultCatalog()
Returns the defaultCatalog field.

Returns:
defaultCatalog

setDefaultCatalog

public void setDefaultCatalog(String defaultCatalog)
Sets the defaultCatalog setting for newly created connections. If not set, use driver default.

Parameters:
defaultCatalog - the defaultCatalog to set

getDefaultTransactionIsolation

public String getDefaultTransactionIsolation()
Returns the defaultTransactionIsolation field.

Returns:
defaultTransactionIsolation

setDefaultTransactionIsolation

public void setDefaultTransactionIsolation(String defaultTransactionIsolation)
Sets the defaultTransactionIsolation. Should be set to one of: NONE, READ_COMMITTED, READ_UNCOMMITTED, REPEATABLE_READ or SERIALIZABLE. If not set, will use driver default.

Parameters:
defaultTransactionIsolation - the defaultTransactionIsolation to set

getDefaultTransactionIsolationValue

protected int getDefaultTransactionIsolationValue()
Returns the defaultTransactionIsolationValue field.

Returns:
defaultTransactionIsolationValue

setDefaultTransactionIsolationValue

protected void setDefaultTransactionIsolationValue(int defaultTransactionIsolationValue)
Sets the defaultTransactionIsolationValue.

Parameters:
defaultTransactionIsolationValue - the defaultTransactionIsolationValue to set

setProperties

public void setProperties(Properties props)
                   throws Exception
Sets the properties by reading off entries in the given parameter (where each key is equivalent to the field name)

Parameters:
props - Parameter list to set
Throws:
Exception - on error

isExternalAuth

public boolean isExternalAuth()
Returns the current externalAuth setting.

Returns:
externalAuth setting

setExternalAuth

public void setExternalAuth(boolean externalAuth)
If set to true, no attempts at passing in a username/password will be attempted when trying to obtain a raw (driver) connection. Useful for cases when you already have another mechanism on authentication eg NTLM.

Parameters:
externalAuth - True to enable external auth.

sanitize

public void sanitize()
Performs validation on the config object.


loadProperties

protected void loadProperties(String filename)
Loads the given properties file using the classloader.

Parameters:
filename - Config filename to load

toString

public String toString()
Overrides:
toString in class Object

loadClass

protected Class<?> loadClass(String clazz)
                      throws ClassNotFoundException
Loads the given class, respecting the given classloader.

Parameters:
clazz - class to load
Returns:
Loaded class
Throws:
ClassNotFoundException

getClassLoader

public ClassLoader getClassLoader()
Returns the currently active classloader.

Returns:
the classLoader

setClassLoader

public void setClassLoader(ClassLoader classLoader)
Sets the classloader to use to load JDBC driver and hooks (set to null to use default).

Parameters:
classLoader - the classLoader to set

clone

public BoneCPConfig clone()
                   throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

hasSameConfiguration

public boolean hasSameConfiguration(BoneCPConfig that)
Returns true if this instance has the same config as a given config.

Parameters:
that -
Returns:
true if the instance has the same config, false otherwise.


Copyright © 2009-2011 JolBox. All Rights Reserved.