org.apache.commons.dbcp
public class BasicDataSource extends Object implements DataSource
Basic implementation of javax.sql.DataSource
that is
configured via JavaBeans properties. This is not the only way to
combine the commons-dbcp and commons-pool packages,
but provides a "one stop shopping" solution for basic requirements.
Version: $Revision: 1.37 $ $Date: 2004/06/09 18:21:23 $
Method Summary | |
---|---|
void | addConnectionProperty(String name, String value)
Add a custom connection property to the set that will be passed to our
JDBC driver. |
void | close()
Close and release all connections that are currently stored in the
connection pool associated with our data source.
|
Connection | getConnection()
Create (if necessary) and return a connection to the database.
|
Connection | getConnection(String username, String password)
Create (if necessary) and return a connection to the database.
|
boolean | getDefaultAutoCommit() |
String | getDefaultCatalog() |
boolean | getDefaultReadOnly() |
int | getDefaultTransactionIsolation() |
String | getDriverClassName() |
int | getInitialSize() |
boolean | getLogAbandoned()
Flag to log stack traces for application code which abandoned
a Statement or Connection.
|
int | getLoginTimeout()
Return the login timeout (in seconds) for connecting to the database.
|
PrintWriter | getLogWriter()
Return the log writer being used by this data source.
|
int | getMaxActive() |
int | getMaxIdle() |
int | getMaxOpenPreparedStatements() |
long | getMaxWait() |
long | getMinEvictableIdleTimeMillis() |
int | getMinIdle() |
int | getNumActive()
[Read Only] The current number of active connections that have been
allocated from this data source. |
int | getNumIdle()
[Read Only] The current number of idle connections that are waiting
to be allocated from this data source. |
int | getNumTestsPerEvictionRun() |
String | getPassword() |
boolean | getRemoveAbandoned()
Flag to remove abandoned connections if they exceed the
removeAbandonedTimout.
|
int | getRemoveAbandonedTimeout()
Timeout in seconds before an abandoned connection can be removed.
|
boolean | getTestOnBorrow() |
boolean | getTestOnReturn() |
boolean | getTestWhileIdle() |
long | getTimeBetweenEvictionRunsMillis() |
String | getUrl() |
String | getUsername() |
String | getValidationQuery() |
boolean | isAccessToUnderlyingConnectionAllowed()
Returns the value of the accessToUnderlyingConnectionAllowed property.
|
boolean | isPoolPreparedStatements()
Returns true if we are pooling statements. |
void | removeConnectionProperty(String name) |
void | setAccessToUnderlyingConnectionAllowed(boolean allow)
Sets the value of the accessToUnderlyingConnectionAllowed property.
|
void | setDefaultAutoCommit(boolean defaultAutoCommit) |
void | setDefaultCatalog(String defaultCatalog) |
void | setDefaultReadOnly(boolean defaultReadOnly) |
void | setDefaultTransactionIsolation(int defaultTransactionIsolation) |
void | setDriverClassName(String driverClassName) |
void | setInitialSize(int initialSize) |
void | setLogAbandoned(boolean logAbandoned) |
void | setLoginTimeout(int loginTimeout)
Set the login timeout (in seconds) for connecting to the database.
|
void | setLogWriter(PrintWriter logWriter)
Set the log writer being used by this data source.
|
void | setMaxActive(int maxActive) |
void | setMaxIdle(int maxIdle) |
void | setMaxOpenPreparedStatements(int maxOpenStatements) |
void | setMaxWait(long maxWait) |
void | setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) |
void | setMinIdle(int minIdle) |
void | setNumTestsPerEvictionRun(int numTestsPerEvictionRun) |
void | setPassword(String password) |
void | setPoolPreparedStatements(boolean poolingStatements)
Sets whether to pool statements or not. |
void | setRemoveAbandoned(boolean removeAbandoned) |
void | setRemoveAbandonedTimeout(int removeAbandonedTimeout) |
void | setTestOnBorrow(boolean testOnBorrow) |
void | setTestOnReturn(boolean testOnReturn) |
void | setTestWhileIdle(boolean testWhileIdle) |
void | setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) |
void | setUrl(String url) |
void | setUsername(String username) |
void | setValidationQuery(String validationQuery) |
Parameters: name Name of the custom connection property value Value of the custom connection property
Throws: SQLException if a database error occurs
Throws: SQLException if a database access error occurs
Parameters: username Database user on whose behalf the Connection is being made password The database user's password
Throws: SQLException if a database access error occurs
Deprecated:
Flag to log stack traces for application code which abandoned a Statement or Connection. Defaults to false. Logging of abandoned Statements and Connections adds overhead for every Connection open or new Statement because a stack trace has to be generated.Throws: SQLException if a database access error occurs
Throws: SQLException if a database access error occurs
Deprecated:
Flag to remove abandoned connections if they exceed the removeAbandonedTimout. Set to true or false, default false. If set to true a connection is considered abandoned and eligible for removal if it has been idle longer than the removeAbandonedTimeout. Setting this to true can recover db connections from poorly written applications which fail to close a connection.Deprecated:
Timeout in seconds before an abandoned connection can be removed. Defaults to 300 seconds.Returns: true if access to the underlying is allowed, false otherwise.
Returns: boolean
Parameters: allow Access to the underlying connection is granted when true.
Deprecated:
Parameters: logAbandoned
Parameters: loginTimeout The new login timeout, or zero for no timeout
Throws: SQLException if a database access error occurs
Parameters: logWriter The new log writer
Throws: SQLException if a database access error occurs
Parameters: poolPreparedStatements pooling on or off
Deprecated:
Parameters: removeAbandoned
Deprecated:
Parameters: removeAbandonedTimeout