Java org.apache.commons.dbcp2 BasicDataSource fields, constructors, methods, implement or subclass

Example usage for Java org.apache.commons.dbcp2 BasicDataSource fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for org.apache.commons.dbcp2 BasicDataSource.

The text is from its open source code.

Subclass

org.apache.commons.dbcp2.BasicDataSource has subclasses.
Click this link to see all its subclasses.

Constructor

Method

voidaddConnectionProperty(String name, String value)
Add a custom connection property to the set that will be passed to our JDBC driver.
voidclose()

Closes and releases all idle connections that are currently stored in the connection pool associated with this data source.

Connections that are checked out to clients when this method is invoked are not affected.

ClassgetClass()
Returns the runtime class of this Object .
ConnectiongetConnection()
Create (if necessary) and return a connection to the database.
IntegergetDefaultQueryTimeout()
Obtain the default query timeout that will be used for java.sql.Statement Statement s created from this connection.
DrivergetDriver()
Returns the JDBC Driver that has been configured for use by this pool.
StringgetDriverClassName()
Returns the jdbc driver class name.
intgetInitialSize()
Returns the initial size of the connection pool.
StringgetJmxName()
Returns the JMX name that has been requested for this DataSource.
longgetMaxConnLifetimeMillis()
Returns the maximum permitted lifetime of a connection in milliseconds.
intgetMaxIdle()

Returns the maximum number of connections that can remain idle in the pool.

intgetMaxTotal()

Returns the maximum number of active connections that can be allocated at the same time.

longgetMinEvictableIdleTimeMillis()
Returns the #minEvictableIdleTimeMillis property.
intgetMinIdle()
Returns the minimum number of idle connections in the pool.
intgetNumActive()
[Read Only] The current number of active connections that have been allocated from this data source.
intgetNumIdle()
[Read Only] The current number of idle connections that are waiting to be allocated from this data source.
StringgetPassword()
Returns the password passed to the JDBC driver to establish connections.
StringgetUrl()
Returns the JDBC connection #url property.
StringgetUsername()
Returns the JDBC connection #username property.
StringgetValidationQuery()
Returns the validation query used to validate connections before returning them.
booleanisPoolPreparedStatements()
Returns true if we are pooling statements.
voidsetAbandonedLogWriter(PrintWriter logWriter)
Sets the log writer to be used by this configuration to log information on abandoned objects.
voidsetAbandonedUsageTracking(boolean usageTracking)
If the connection pool implements org.apache.commons.pool2.UsageTracking UsageTracking , configure whether the connection pool should record a stack trace every time a method is called on a pooled connection and retain the most recent stack trace to aid debugging of abandoned connections.
voidsetAccessToUnderlyingConnectionAllowed(boolean allow)

Sets the value of the accessToUnderlyingConnectionAllowed property.

voidsetCacheState(boolean cacheState)
Sets the state caching flag.
voidsetConnectionInitSqls(Collection connectionInitSqls)
Sets the list of SQL statements to be executed when a physical connection is first created.
voidsetConnectionProperties(String connectionProperties)
Sets the connection properties passed to driver.connect(...).
voidsetDefaultAutoCommit(Boolean defaultAutoCommit)

Sets default auto-commit state of connections returned by this datasource.

Note: this method currently has no effect once the pool has been initialized.

voidsetDefaultCatalog(String defaultCatalog)

Sets the default catalog.

Note: this method currently has no effect once the pool has been initialized.

voidsetDefaultQueryTimeout(Integer defaultQueryTimeout)
Set the default query timeout that will be used for java.sql.Statement Statement s created from this connection.
voidsetDefaultReadOnly(Boolean defaultReadOnly)

Sets defaultReadonly property.

Note: this method currently has no effect once the pool has been initialized.

voidsetDefaultTransactionIsolation(int defaultTransactionIsolation)

Sets the default transaction isolation state for returned connections.

Note: this method currently has no effect once the pool has been initialized.

voidsetDisconnectionSqlCodes(Collection disconnectionSqlCodes)
Sets the SQL_STATE codes considered to signal fatal conditions.
voidsetDriver(Driver driver)
Sets the JDBC Driver instance to use for this pool.
voidsetDriverClassLoader(ClassLoader driverClassLoader)

Sets the class loader to be used to load the JDBC driver.

Note: this method currently has no effect once the pool has been initialized.

voidsetDriverClassName(String driverClassName)

Sets the jdbc driver class name.

Note: this method currently has no effect once the pool has been initialized.

voidsetEnableAutoCommitOnReturn(boolean enableAutoCommitOnReturn)
Sets the value of the flag that controls whether or not connections being returned to the pool will be checked and configured with Connection#setAutoCommit(boolean) Connection.setAutoCommit(true) if the auto commit setting is false when the connection is returned.
voidsetEvictionPolicyClassName(String evictionPolicyClassName)
Sets the EvictionPolicy implementation to use with this connection pool.
voidsetFastFailValidation(boolean fastFailValidation)
voidsetInitialSize(int initialSize)

Sets the initial size of the connection pool.

Note: this method currently has no effect once the pool has been initialized.

voidsetJmxName(String jmxName)
Sets the JMX name that has been requested for this DataSource.
voidsetLifo(boolean lifo)
Sets the LIFO property.
voidsetLogAbandoned(boolean logAbandoned)
voidsetLogExpiredConnections(boolean logExpiredConnections)
When #getMaxConnLifetimeMillis() is set to limit connection lifetime, this property determines whether or not log messages are generated when the pool closes connections due to maximum lifetime exceeded.
voidsetLogWriter(PrintWriter logWriter)

Sets the log writer being used by this data source.

Calls #createDataSource() , so has the side effect of initializing the connection pool.

voidsetMaxConnLifetimeMillis(long maxConnLifetimeMillis)

Sets the maximum permitted lifetime of a connection in milliseconds.

voidsetMaxIdle(int maxIdle)
Sets the maximum number of connections that can remain idle in the pool.
voidsetMaxOpenPreparedStatements(int maxOpenStatements)

Sets the value of the maxOpenPreparedStatements property.

Note: this method currently has no effect once the pool has been initialized.

voidsetMaxTotal(int maxTotal)
Sets the maximum total number of idle and borrows connections that can be active at the same time.
voidsetMaxWaitMillis(long maxWaitMillis)
Sets the MaxWaitMillis property.
voidsetMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)
Sets the #minEvictableIdleTimeMillis property.
voidsetMinIdle(int minIdle)
Sets the minimum number of idle connections in the pool.
voidsetNumTestsPerEvictionRun(int numTestsPerEvictionRun)
Sets the value of the #numTestsPerEvictionRun property.
voidsetPassword(String password)

Sets the #password .

Note: this method currently has no effect once the pool has been initialized.

voidsetPoolPreparedStatements(boolean poolingStatements)

Sets whether to pool statements or not.

Note: this method currently has no effect once the pool has been initialized.

voidsetRemoveAbandonedOnBorrow(boolean removeAbandonedOnBorrow)
voidsetRemoveAbandonedOnMaintenance(boolean removeAbandonedOnMaintenance)
voidsetRemoveAbandonedTimeout(int removeAbandonedTimeout)

Sets the timeout in seconds before an abandoned connection can be removed.

Setting this property has no effect if #getRemoveAbandonedOnBorrow() and #getRemoveAbandonedOnMaintenance() are false.

voidsetRollbackOnReturn(boolean rollbackOnReturn)
Sets the flag that controls if a connection will be rolled back when it is returned to the pool if auto commit is not enabled and the connection is not read only.
voidsetSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis)
Sets the minimum amount of time a connection may sit idle in the pool before it is eligible for eviction by the idle object evictor, with the extra condition that at least "minIdle" connections remain in the pool.
voidsetTestOnBorrow(boolean testOnBorrow)
Sets the #testOnBorrow property.
voidsetTestOnCreate(boolean testOnCreate)
Sets the #testOnCreate property.
voidsetTestOnReturn(boolean testOnReturn)
Sets the testOnReturn property.
voidsetTestWhileIdle(boolean testWhileIdle)
Sets the testWhileIdle property.
voidsetTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)
Sets the #timeBetweenEvictionRunsMillis property.
voidsetUrl(String url)

Sets the #url .

Note: this method currently has no effect once the pool has been initialized.

voidsetUsername(String username)

Sets the #username .

Note: this method currently has no effect once the pool has been initialized.

voidsetValidationQuery(String validationQuery)

Sets the #validationQuery .

Note: this method currently has no effect once the pool has been initialized.

voidsetValidationQueryTimeout(int timeout)
Sets the validation query timeout, the amount of time, in seconds, that connection validation will wait for a response from the database when executing a validation query.
StringtoString()
Returns a string representation of the object.