public class ViburDBCPDataSource extends ViburConfig implements ViburDataSource
getConnection() method. The
lifecycle operations of this DataSource, as well as the other specific to it operations, are
defined by the ViburDataSource interface.DataSource,
ConnectionFactory| Modifier and Type | Class and Description |
|---|---|
static interface |
ViburDBCPDataSource.ConnectionInvalidator |
ViburDataSource.StateDEFAULT_PROPERTIES_CONFIG_FILE_NAME, DEFAULT_XML_CONFIG_FILE_NAME, IS_VALID_QUERY, SQLSTATE_CONN_INIT_ERROR, SQLSTATE_INTERRUPTED_ERROR, SQLSTATE_OBJECT_CLOSED_ERROR, SQLSTATE_POOL_CLOSED_ERROR, SQLSTATE_POOL_NOTSTARTED_ERROR, SQLSTATE_TIMEOUT_ERROR, SQLSTATE_WRAPPER_ERROR| Constructor and Description |
|---|
ViburDBCPDataSource()
Default constructor for programmatic configuration via the
ViburConfig
setter methods. |
ViburDBCPDataSource(Properties properties)
Initialization via the given properties.
|
ViburDBCPDataSource(String configFileName)
Initialization via properties file name.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
A synonym for
ViburDataSource.terminate(). |
Connection |
getConnection() |
Connection |
getConnection(String username,
String password) |
int |
getLoginTimeout() |
PrintWriter |
getLogWriter() |
Connection |
getNonPooledConnection()
Returns a raw (non-pooled) JDBC Connection using the default username and password.
|
Connection |
getNonPooledConnection(String username,
String password)
Returns a raw (non-pooled) JDBC Connection using the supplied username and password.
|
Logger |
getParentLogger() |
ViburDataSource.State |
getState()
Returns this DataSource current state.
|
TakenConnection[] |
getTakenConnections()
Returns an array of all taken proxy Connections.
|
String |
getTakenConnectionsStackTraces()
Generates information about all currently taken connections, including the stack traces of the threads
that have taken them, plus the threads names and states.
|
boolean |
isWrapperFor(Class<?> iface) |
void |
setLoginTimeout(int seconds) |
void |
setLogWriter(PrintWriter out) |
void |
severConnection(Connection connection)
Severs the supplied connection which can either be a pooled connection retrieved via calling
one of the
ViburDataSource.getConnection() methods or a raw non-pooled connection retrieved via calling
one of the ViburDataSource.getNonPooledConnection() methods. |
void |
start()
Starts this DataSource.
|
void |
terminate()
Terminates this DataSource.
|
<T> T |
unwrap(Class<T> iface) |
getAcquireRetryAttempts, getAcquireRetryDelayInMs, getConcurrentCollection, getConnectionFactory, getConnectionIdleLimitInSeconds, getConnectionTimeoutInMs, getConnector, getConnHooks, getCriticalSQLStates, getDefaultAutoCommit, getDefaultCatalog, getDefaultReadOnly, getDefaultTransactionIsolation, getDefaultTransactionIsolationIntValue, getDriver, getDriverClassName, getDriverProperties, getExternalDataSource, getInitSQL, getInvocationHooks, getJdbcUrl, getJmxName, getLogConnectionLongerThanMs, getLoginTimeoutInSeconds, getLogLargeResultSet, getLogLineRegex, getLogQueryExecutionLongerThanMs, getName, getNetworkTimeoutExecutor, getPassword, getPool, getPoolInitialSize, getPoolMaxSize, getPoolReducer, getPoolReducerClass, getReducerSamples, getReducerTimeIntervalInSeconds, getStatementCache, getStatementCacheMaxSize, getTakenConnectionsFormatter, getTestConnectionQuery, getUsername, getValidateTimeoutInSeconds, isAllowConnectionAfterTermination, isAllowUnwrapping, isClearSQLWarnings, isEnableJMX, isIncludeQueryParameters, isLogAllStackTracesOnTimeout, isLogStackTraceForLargeResultSet, isLogStackTraceForLongConnection, isLogStackTraceForLongQueryExecution, isLogTakenConnectionsOnTimeout, isPoolEnableConnectionTracking, isPoolFair, isResetDefaultsAfterUse, isUseNetworkTimeout, setAcquireRetryAttempts, setAcquireRetryDelayInMs, setAllowConnectionAfterTermination, setAllowUnwrapping, setClearSQLWarnings, setConcurrentCollection, setConnectionFactory, setConnectionIdleLimitInSeconds, setConnectionTimeoutInMs, setConnector, setCriticalSQLStates, setDefaultAutoCommit, setDefaultCatalog, setDefaultReadOnly, setDefaultTransactionIsolation, setDefaultTransactionIsolationIntValue, setDriver, setDriverClassName, setDriverProperties, setEnableJMX, setExternalDataSource, setIncludeQueryParameters, setInitSQL, setJdbcUrl, setLogAllStackTracesOnTimeout, setLogConnectionLongerThanMs, setLoginTimeoutInSeconds, setLogLargeResultSet, setLogLineRegex, setLogQueryExecutionLongerThanMs, setLogStackTraceForLargeResultSet, setLogStackTraceForLongConnection, setLogStackTraceForLongQueryExecution, setLogTakenConnectionsOnTimeout, setName, setNetworkTimeoutExecutor, setPassword, setPool, setPoolEnableConnectionTracking, setPoolFair, setPoolInitialSize, setPoolMaxSize, setPoolReducer, setPoolReducerClass, setReducerSamples, setReducerTimeIntervalInSeconds, setResetDefaultsAfterUse, setStatementCache, setStatementCacheMaxSize, setTakenConnectionsFormatter, setTestConnectionQuery, setUseNetworkTimeout, setUsername, setValidateTimeoutInSeconds, toStringpublic ViburDBCPDataSource()
ViburConfig
setter methods.public ViburDBCPDataSource(String configFileName) throws ViburDBCPException
configFileName can be null in which case the default resource
file names ViburConfig.DEFAULT_XML_CONFIG_FILE_NAME or ViburConfig.DEFAULT_PROPERTIES_CONFIG_FILE_NAME
will be loaded, in this order.
configFileName - the properties config file nameViburDBCPException - if cannot configure this DataSource successfullypublic ViburDBCPDataSource(Properties properties) throws ViburDBCPException
properties - the given propertiesViburDBCPException - if cannot configure this DataSource successfullypublic void start()
throws ViburDBCPException
start in interface ViburDataSourceViburDBCPException - if not in a NEW state when started;
if a configuration error is found during start;
if cannot start this DataSource successfully, that is, if cannot successfully
initialize/configure the underlying SQL system, if cannot create the underlying SQL connections,
if cannot initialize the configured/needed JDBC Driver, if cannot create the configured pool reducer,
or if cannot initialize JMXpublic void terminate()
ViburDataSourceterminate in interface ViburDataSourcepublic void close()
ViburDataSourceViburDataSource.terminate(). Overrides the AutoCloseable's method in order to overrule
the throwing of a checked Exception.close in interface AutoCloseableclose in interface ViburDataSourcepublic ViburDataSource.State getState()
ViburDataSourcegetState in interface ViburDataSourcepublic Connection getConnection() throws SQLException
ViburDataSourcegetConnection in interface DataSourcegetConnection in interface ViburDataSourceSQLExceptionpublic Connection getConnection(String username, String password) throws SQLException
ViburDataSourceThis method will return a raw (non-pooled) JDBC Connection when called with credentials different than the configured default credentials.
getConnection in interface DataSourcegetConnection in interface ViburDataSourceSQLExceptionpublic Connection getNonPooledConnection() throws SQLException
ViburDataSourcegetNonPooledConnection in interface ViburDataSourceSQLException - if an error occurs while creating the connectionpublic Connection getNonPooledConnection(String username, String password) throws SQLException
ViburDataSourcegetNonPooledConnection in interface ViburDataSourceusername - the database usernamepassword - the database passwordSQLException - if an error occurs while creating the connectionpublic void severConnection(Connection connection) throws SQLException
ViburDataSourceViburDataSource.getConnection() methods or a raw non-pooled connection retrieved via calling
one of the ViburDataSource.getNonPooledConnection() methods. If the supplied connection is pooled, it will
be closed and removed from the pool and its underlying raw connection will be closed, too. In the
case when the supplied connection is non-pooled, it will be just closed.
Calling this method on a pooled or non-pooled connection that is already closed is a no-op.
When the severConnection method returns, the connection on which it is called will
be marked as closed.
severConnection in interface ViburDataSourceconnection - the connection to be severedSQLException - if an error occurs while closing/severing the connectionpublic String getTakenConnectionsStackTraces()
ViburDataSourceViburConfig.poolEnableConnectionTracking option is enabled.
The exact format of the logged message is controlled by ViburConfig.takenConnectionsFormatter.
Also see ViburConfig.logTakenConnectionsOnTimeout and ViburDataSource.getTakenConnections().
getTakenConnectionsStackTraces in interface ViburDataSourcepublic TakenConnection[] getTakenConnections()
ViburDataSourceViburConfig.poolEnableConnectionTracking option is enabled.
getTakenConnections in interface ViburDataSourcepublic PrintWriter getLogWriter() throws SQLException
getLogWriter in interface CommonDataSourceSQLExceptionpublic void setLogWriter(PrintWriter out) throws SQLException
setLogWriter in interface CommonDataSourceSQLExceptionpublic void setLoginTimeout(int seconds)
setLoginTimeout in interface CommonDataSourcepublic int getLoginTimeout()
getLoginTimeout in interface CommonDataSourcepublic Logger getParentLogger() throws SQLFeatureNotSupportedException
getParentLogger in interface CommonDataSourceSQLFeatureNotSupportedExceptionpublic <T> T unwrap(Class<T> iface) throws SQLException
unwrap in interface WrapperSQLExceptionpublic boolean isWrapperFor(Class<?> iface)
isWrapperFor in interface WrapperCopyright © 2013-2019 vibur.org. All Rights Reserved.