Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 85938 invoked from network); 23 Jun 2005 06:16:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 23 Jun 2005 06:16:48 -0000 Received: (qmail 93598 invoked by uid 500); 23 Jun 2005 06:16:43 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 93336 invoked by uid 500); 23 Jun 2005 06:16:41 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: 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 93322 invoked by uid 99); 23 Jun 2005 06:16:41 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Jun 2005 23:16:41 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [195.130.132.56] (HELO adicia.telenet-ops.be) (195.130.132.56) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Jun 2005 23:16:42 -0700 Received: from localhost (localhost.localdomain [127.0.0.1]) by adicia.telenet-ops.be (Postfix) with SMTP id 3A23944152 for ; Thu, 23 Jun 2005 08:16:40 +0200 (MEST) Received: from [127.0.0.1] (d51A55340.access.telenet.be [81.165.83.64]) by adicia.telenet-ops.be (Postfix) with ESMTP id 295DC440A6 for ; Thu, 23 Jun 2005 08:16:40 +0200 (MEST) Message-ID: <42BA53C3.9080709@pandora.be> Date: Thu, 23 Jun 2005 08:16:35 +0200 From: Dirk Verbeeck User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jakarta Commons Users List Subject: Re: [dbcp] use of BasicDataSourceFactory.createDataSource(Properties) References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi, Answers inline Pramodh Peddi wrote: > Hi DBCP experts, > Is anyone using BasicDataSourceFactory.createDataSource(Properties) to > create a BasicDataSource object (using version 1.2)? I have not yet used > this, but I desire to use this. I can see few 'issues' when I use it: This method is used by tomcat so a lot of users are using this piece of code. > * Every time BasicDataSource is created, we need to create a > Properties object. Is this not going to be a performance hit? Creating the Properties object isn't the performance hit. Always recreating a BasicDataSource is. The BasicDataSource is your pool of connections, if you are always recreating it then you don't have pooling behaviour. > * To avoid the above performance hit, is it ok if I cache > BasicDataSource (make it static variable) and re-use it every time > connection is borrowed from pool. Yes, this is the normal use of a BasicDataSource. You create the pool once and then borrow connections from it. BasicDataSource is thread-safe so you don't need to add synchronizations. > * If BasicDataSource caching is ok, do read-only methods like > getNumIdle() and getNumActive() return the right values? Yes > * Do I still need to define the Resource ( name="jdbc/ImprivataDB" auth="Container" type="javax.sql.DataSource"/>) > in server.xml and web.xml? No, if you are creating a BasicDataSource yourself then you don't need to configure anything else. The configuration files server.xml and web.xml are only used when tomcat creates the BasicDataSource and you get the DataSource using JNDI. > * Are there any examples around which uses > BasicDataSourceFactory.createDataSource(Properties) to create > BasicDataSource? http://jakarta.apache.org/commons/dbcp/xref-test/org/apache/commons/dbcp/TestBasicDataSourceFactory.html#50 > Thanks in advance for the answers, > Pramodh. Cheers Dirk --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org