Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 61366 invoked from network); 21 Feb 2004 13:11:32 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 21 Feb 2004 13:11:32 -0000 Received: (qmail 12292 invoked by uid 500); 21 Feb 2004 13:11:25 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 12272 invoked by uid 500); 21 Feb 2004 13:11:25 -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 12258 invoked from network); 21 Feb 2004 13:11:24 -0000 Received: from unknown (HELO elpis.telenet-ops.be) (195.130.132.40) by daedalus.apache.org with SMTP; 21 Feb 2004 13:11:24 -0000 Received: from localhost (adicia.telenet-ops.be [195.130.132.56]) by elpis.telenet-ops.be (Postfix) with SMTP id 3982037EF1 for ; Sat, 21 Feb 2004 14:11:25 +0100 (MET) Received: from pandora.be (D5E05AE7.kabel.telenet.be [213.224.90.231]) by adicia.telenet-ops.be (Postfix) with ESMTP id 19A701F707F for ; Sat, 21 Feb 2004 14:11:25 +0100 (MET) Message-ID: <403758F6.5040401@pandora.be> Date: Sat, 21 Feb 2004 14:11:18 +0100 From: Dirk Verbeeck User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jakarta Commons Users List Subject: Re: DBCP and the ConnectionPoolDataSource Interface References: <15E8CE164083D611B27400065B3F00E701F4F06D@lexexcu01.gs.acs-inc.com> In-Reply-To: <15E8CE164083D611B27400065B3F00E701F4F06D@lexexcu01.gs.acs-inc.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N There are 2 almost separate connection pool implementations in the DBCP distribution. The first one is located in org.apache.commons.dbcp.* Starting from DriverConnectionFactory it builds a PoolingDataSource called BasicDataSource (the default tomcat datasource). More info can be found here: http://jakarta.apache.org/commons/dbcp/configuration.html http://jakarta.apache.org/commons/dbcp/guide/index.html It provides all pooling features for the DataSource.getConnection() method. (see configuration page for details) The second pool implementation around the interface javax.sql.ConnectionPoolDataSource is located in: org.apache.commons.dbcp.datasources.* It is mostly used for its "per user" connection pools. factory org.apache.commons.dbcp.datasources.PerUserPoolDataSourceFactory defaultMaxActive100 defaultMaxIdle30 defaultMaxWait10000 dataSourceNamejava:comp/env/jdbc/peruserCPDS The dataSourceName refers to a datasource implementing the javax.sql.ConnectionPoolDataSource interface. You can use a database specific implementation or the generic DBCP one: factory org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS user password driver... url.... If you need a pooled getConnection() methods use BasicDataSource otherwise use PerUserPoolDataSource (with DriverAdapterCPDS or a database specific ConnectionPoolDataSource) One last remark, if you going to use the MySQL driver for the ConnectionPoolDataSource be aware of the following issue: http://issues.apache.org/eyebrowse/ReadMsg?listName=commons-user@jakarta.apache.org&msgNo=3792 Regards Dirk Fumo, Vince wrote: > I have three different databases I need to manage and I want to use > connection pooling datasources registered in JNDI as their commonality in my > application. From what I can gather, if the JDBC driver from the db vendor > has a DataSource implementation that implements ConnectionPoolDataSource, I > can easily register it in JNDI. It's also my understanding that the > management of the pool itself is not the responsibility of the individual > JDBC driver. I'm hoping that DBCP can handle my management. > > What I'd like to implement is a simple method that will take a > ConnectionPoolDataSource object, wrap it in pool management and return a > PoolingDataSource object that I can then register in JNDI. > > I've looked at the Dialog in the javadoc and I understand how to create a > pool given a connection string (using the DriverConnectionFactory) but I'm > not sure how to replace this ConnectionFactory with the > ConnectionPoolDataSource object. I'm not even sure if this is what I should > be doing. > > I'm sorry if this seems a simple question, but I've looked everywhere and I > can't seem to find anything that references a connection between > ConnectionPoolDataSource and DBCP (other than the reference in the javadoc > for DriverAdapterCPDS. > > Thanks for your help. --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org