Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.commons.dbcp.BasicDataSource
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.
Nested Class Summary |
Method Summary | |
void |
|
void |
|
Connection |
|
Connection |
|
boolean | |
String | |
boolean | |
int | |
String | |
int | |
boolean |
|
PrintWriter |
|
int |
|
int | |
int | |
int | |
long | |
long | |
int | |
int |
|
int |
|
int | |
String | |
boolean |
|
int |
|
boolean | |
boolean | |
boolean | |
long | |
String |
|
String | |
String | |
boolean |
|
boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
public void addConnectionProperty(java.lang.String name, java.lang.String value)
Add a custom connection property to the set that will be passed to our JDBC driver. This MUST be called before the first connection is retrieved (along with all the other configuration property setters).
- Parameters:
name
- Name of the custom connection propertyvalue
- Value of the custom connection property
public void close() throws SQLException
Close and release all connections that are currently stored in the connection pool associated with our data source.
- Throws:
SQLException
- if a database error occurs
public Connection getConnection() throws SQLException
Create (if necessary) and return a connection to the database.
- Throws:
SQLException
- if a database access error occurs
public Connection getConnection(java.lang.String username, java.lang.String password) throws SQLException
Create (if necessary) and return a connection to the database.
- Parameters:
username
- Database user on whose behalf the Connection is being madepassword
- The database user's password
- Throws:
SQLException
- if a database access error occurs
public boolean getDefaultAutoCommit()
public boolean getDefaultReadOnly()
public int getDefaultTransactionIsolation()
public int getInitialSize()
public boolean getLogAbandoned()
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.
public PrintWriter getLogWriter() throws SQLException
Return the log writer being used by this data source.
- Throws:
SQLException
- if a database access error occurs
public int getLoginTimeout() throws SQLException
Return the login timeout (in seconds) for connecting to the database.
- Throws:
SQLException
- if a database access error occurs
public int getMaxActive()
public int getMaxIdle()
public int getMaxOpenPreparedStatements()
public long getMaxWait()
public long getMinEvictableIdleTimeMillis()
public int getMinIdle()
public int getNumActive()
[Read Only] The current number of active connections that have been allocated from this data source.
public int getNumIdle()
[Read Only] The current number of idle connections that are waiting to be allocated from this data source.
public int getNumTestsPerEvictionRun()
public boolean getRemoveAbandoned()
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.
public int getRemoveAbandonedTimeout()
Deprecated.
Timeout in seconds before an abandoned connection can be removed. Defaults to 300 seconds.
public boolean getTestOnBorrow()
public boolean getTestOnReturn()
public boolean getTestWhileIdle()
public long getTimeBetweenEvictionRunsMillis()
public boolean isAccessToUnderlyingConnectionAllowed()
Returns the value of the accessToUnderlyingConnectionAllowed property.
- Returns:
- true if access to the underlying is allowed, false otherwise.
public boolean isPoolPreparedStatements()
Returns true if we are pooling statements.
- Returns:
- boolean
public void removeConnectionProperty(java.lang.String name)
public void setAccessToUnderlyingConnectionAllowed(boolean allow)
Sets the value of the accessToUnderlyingConnectionAllowed property. It controls if the PoolGuard allows access to the underlying connection. (Default: false)
- Parameters:
allow
- Access to the underlying connection is granted when true.
public void setDefaultAutoCommit(boolean defaultAutoCommit)
public void setDefaultCatalog(java.lang.String defaultCatalog)
public void setDefaultReadOnly(boolean defaultReadOnly)
public void setDefaultTransactionIsolation(int defaultTransactionIsolation)
public void setDriverClassName(java.lang.String driverClassName)
public void setInitialSize(int initialSize)
public void setLogAbandoned(boolean logAbandoned)
Deprecated.
- Parameters:
logAbandoned
-
public void setLogWriter(PrintWriter logWriter) throws SQLException
Set the log writer being used by this data source.
- Parameters:
logWriter
- The new log writer
- Throws:
SQLException
- if a database access error occurs
public void setLoginTimeout(int loginTimeout) throws SQLException
Set the login timeout (in seconds) for connecting to the database.
- Parameters:
loginTimeout
- The new login timeout, or zero for no timeout
- Throws:
SQLException
- if a database access error occurs
public void setMaxActive(int maxActive)
public void setMaxIdle(int maxIdle)
public void setMaxOpenPreparedStatements(int maxOpenStatements)
public void setMaxWait(long maxWait)
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)
public void setMinIdle(int minIdle)
public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun)
public void setPassword(java.lang.String password)
public void setPoolPreparedStatements(boolean poolingStatements)
Sets whether to pool statements or not.
- Parameters:
public void setRemoveAbandoned(boolean removeAbandoned)
Deprecated.
- Parameters:
removeAbandoned
-
public void setRemoveAbandonedTimeout(int removeAbandonedTimeout)
Deprecated.
- Parameters:
removeAbandonedTimeout
-
public void setTestOnBorrow(boolean testOnBorrow)
public void setTestOnReturn(boolean testOnReturn)
public void setTestWhileIdle(boolean testWhileIdle)
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)
public void setUrl(java.lang.String url)
public void setUsername(java.lang.String username)
public void setValidationQuery(java.lang.String validationQuery)