http://jakarta.apache.org/commons/dbcp/xref/org/apache/commons/dbcp/BasicDataSource.html#797
To shutdown this pool call ds.close().
"lost" connections are called "abandoned" connections in DBCP config.
Removal of "dead" connections is done by using a validationQuery and related config parameters.
See http://jakarta.apache.org/commons/dbcp/configuration.html for more details.
You have the minimum configuration there. If you are going to use this in a application then take a look at:
BasicDataSourceFactory.createDataSource(Properties properties)
Load all properties from a file into the properties object (properties.load()) and create the DataSource using the factory.
http://jakarta.apache.org/commons/dbcp/apidocs/org/apache/commons/dbcp/BasicDataSourceFactory.html
Same behaviour as setting the properties yourself.
-- Dirk
Scott Purcell wrote:
Hello,
I finally figured out last night how to obtain a DataSource object in a class, and set enough properties to get a connection:
BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName("com.mysql.jdbc.Driver"); ds.setUsername("javauser"); ds.setPassword("javadude"); ds.setUrl(connectURI);
then I get a Connection like so: Connection conn = ds.getConnection()
I am good with all of this, and it works. Now where I am baffled is, where is the pool of connections. Did this create a pool? I know I had to set the commons-pool.jar in my path to get it to run. So does this class create a pool in the background? And if so, do I need to run a thread to shut them down? I am looking at the BasicDataSource javadocs and I see some methods like such:
setInitializeSize(int size) setDefaultAutoCommit(boolean val) etc.
But I am not sure which ones are for cleaning up "lost" or "dead" connections, etc. And would this simple configuration work for a simple web application?
Any input would be appreciated.
Thanks,
Scott K Purcell
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
