|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.dbcp.BasicDataSource
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.
Constructor Summary | |
BasicDataSource()
|
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()
|
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 |
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 |
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 |
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)
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public BasicDataSource()
Method Detail |
public void addConnectionProperty(String name, String value)
name
- Name of the custom connection propertyvalue
- Value of the custom connection propertypublic void close() throws SQLException
SQLException
- if a database error occurspublic Connection getConnection() throws SQLException
getConnection
in interface DataSource
SQLException
- if a database access error occurspublic Connection getConnection(String username, String password) throws SQLException
getConnection
in interface DataSource
username
- Database user on whose behalf the Connection
is being madepassword
- The database user's password
SQLException
- if a database access error occurspublic boolean getDefaultAutoCommit()
public String getDefaultCatalog()
public boolean getDefaultReadOnly()
public int getDefaultTransactionIsolation()
public String getDriverClassName()
public int getInitialSize()
public int getLoginTimeout() throws SQLException
getLoginTimeout
in interface DataSource
SQLException
- if a database access error occurspublic PrintWriter getLogWriter() throws SQLException
getLogWriter
in interface DataSource
SQLException
- if a database access error occurspublic int getMaxActive()
public int getMaxIdle()
public int getMaxOpenPreparedStatements()
public long getMaxWait()
public long getMinEvictableIdleTimeMillis()
public int getMinIdle()
public int getNumActive()
public int getNumIdle()
public int getNumTestsPerEvictionRun()
public String getPassword()
public boolean getTestOnBorrow()
public boolean getTestOnReturn()
public boolean getTestWhileIdle()
public long getTimeBetweenEvictionRunsMillis()
public String getUrl()
public String getUsername()
public String getValidationQuery()
public boolean isAccessToUnderlyingConnectionAllowed()
public boolean isPoolPreparedStatements()
public void removeConnectionProperty(String name)
public void setAccessToUnderlyingConnectionAllowed(boolean allow)
allow
- Access to the underlying connection is granted when true.public void setDefaultAutoCommit(boolean defaultAutoCommit)
public void setDefaultCatalog(String defaultCatalog)
public void setDefaultReadOnly(boolean defaultReadOnly)
public void setDefaultTransactionIsolation(int defaultTransactionIsolation)
public void setDriverClassName(String driverClassName)
public void setInitialSize(int initialSize)
public void setLoginTimeout(int loginTimeout) throws SQLException
setLoginTimeout
in interface DataSource
loginTimeout
- The new login timeout, or zero for no timeout
SQLException
- if a database access error occurspublic void setLogWriter(PrintWriter logWriter) throws SQLException
setLogWriter
in interface DataSource
logWriter
- The new log writer
SQLException
- if a database access error occurspublic 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(String password)
public void setPoolPreparedStatements(boolean poolingStatements)
public void setTestOnBorrow(boolean testOnBorrow)
public void setTestOnReturn(boolean testOnReturn)
public void setTestWhileIdle(boolean testWhileIdle)
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)
public void setUrl(String url)
public void setUsername(String username)
public void setValidationQuery(String validationQuery)
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |