Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 57793 invoked from network); 15 Apr 2005 06:04:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 15 Apr 2005 06:04:47 -0000 Received: (qmail 54142 invoked by uid 500); 15 Apr 2005 06:04:37 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 54119 invoked by uid 500); 15 Apr 2005 06:04:36 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 54105 invoked by uid 99); 15 Apr 2005 06:04:36 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from asia.telenet-ops.be (HELO asia.telenet-ops.be) (195.130.132.59) by apache.org (qpsmtpd/0.28) with ESMTP; Thu, 14 Apr 2005 23:04:35 -0700 Received: from localhost (localhost.localdomain [127.0.0.1]) by asia.telenet-ops.be (Postfix) with SMTP id A320F22409B for ; Fri, 15 Apr 2005 08:04:32 +0200 (MEST) Received: from [127.0.0.1] (dD5E05B29.access.telenet.be [213.224.91.41]) by asia.telenet-ops.be (Postfix) with ESMTP id 35CE622400A for ; Fri, 15 Apr 2005 08:04:29 +0200 (MEST) Message-ID: <425F595A.6000808@pandora.be> Date: Fri, 15 Apr 2005 08:04:10 +0200 From: Dirk Verbeeck User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jakarta Commons Users List Subject: Re: DBCP package BasicDataSource question References: <34385CBC5E8E664EB0007814636AB36A0316D485@exchange1.dimensions.com> In-Reply-To: <34385CBC5E8E664EB0007814636AB36A0316D485@exchange1.dimensions.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N The BasicDataSource class creates a pool for you based on the properties you set (setMaxActive, ...) 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: commons-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: commons-user-help@jakarta.apache.org > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org