public interface ViburDataSource extends DataSource, AutoCloseable
ViburDBCPDataSource lifecycle operations and states. Also, defines specific to Vibur
DataSource operations such as retrieving and manipulating of non-pooled connections as well as operations
giving information about the currently taken from the pool connections.| Modifier and Type | Interface and Description |
|---|---|
static class |
ViburDataSource.State
The possible states in which the DataSource can be.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
A synonym for
terminate(). |
Connection |
getConnection() |
Connection |
getConnection(String username,
String password) |
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.
|
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.
|
void |
severConnection(Connection connection)
Severs the supplied connection which can either be a pooled connection retrieved via calling
one of the
getConnection() methods or a raw non-pooled connection retrieved via calling
one of the getNonPooledConnection() methods. |
void |
start()
Starts this DataSource.
|
void |
terminate()
Terminates this DataSource.
|
getLoginTimeout, getLogWriter, getParentLogger, setLoginTimeout, setLogWriterisWrapperFor, unwrapvoid start()
throws ViburDBCPException
ViburDBCPException - if not in a NEW state when started;
if a configuration error is found during start;
if cannot start this DataSource successfully for any other reasonViburDataSource.State getState()
void terminate()
void close()
terminate(). Overrides the AutoCloseable's method in order to overrule
the throwing of a checked Exception.close in interface AutoCloseableConnection getConnection() throws SQLException
getConnection in interface DataSourceSQLTimeoutException - when the timeout value specified by the
connectionTimeoutInMs has been exceededSQLExceptionConnection getConnection(String username, String password) throws SQLException
This method will return a raw (non-pooled) JDBC Connection when called with credentials different than the configured default credentials.
getConnection in interface DataSourceSQLTimeoutException - when called with the default credentials and when the timeout value specified by
the connectionTimeoutInMs has been exceededSQLExceptionConnection getNonPooledConnection() throws SQLException
SQLException - if an error occurs while creating the connectionConnection getNonPooledConnection(String username, String password) throws SQLException
username - the database usernamepassword - the database passwordSQLException - if an error occurs while creating the connectionvoid severConnection(Connection connection) throws SQLException
getConnection() methods or a raw non-pooled connection retrieved via calling
one of the 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.
connection - the connection to be severedSQLException - if an error occurs while closing/severing the connectionString getTakenConnectionsStackTraces()
ViburConfig.poolEnableConnectionTracking option is enabled.
The exact format of the logged message is controlled by ViburConfig.takenConnectionsFormatter.
Also see ViburConfig.logTakenConnectionsOnTimeout and getTakenConnections().
TakenConnection[] getTakenConnections()
ViburConfig.poolEnableConnectionTracking option is enabled.
Also see getTakenConnectionsStackTraces().
Copyright © 2013-2019 vibur.org. All Rights Reserved.