Return-Path: X-Original-To: apmail-commons-user-archive@www.apache.org Delivered-To: apmail-commons-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 74C7D76C6 for ; Sat, 13 Aug 2011 22:37:14 +0000 (UTC) Received: (qmail 12203 invoked by uid 500); 13 Aug 2011 22:37:13 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 11994 invoked by uid 500); 13 Aug 2011 22:37:12 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 11986 invoked by uid 99); 13 Aug 2011 22:37:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 13 Aug 2011 22:37:12 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of phil.steitz@gmail.com designates 209.85.213.43 as permitted sender) Received: from [209.85.213.43] (HELO mail-yw0-f43.google.com) (209.85.213.43) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 13 Aug 2011 22:37:04 +0000 Received: by ywm3 with SMTP id 3so233381ywm.30 for ; Sat, 13 Aug 2011 15:36:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=Wt1qqGqrKXD07WIDcYZZoxbZ1BVrhTYTNuXpi0lV0cg=; b=Z+JANr+BY4h5gQxjZzWtXkKHyff4HjdBHYYHK4zjlopZ5VatXXZYaBUvuXbTh5LC08 myfOWEYffiY/xfmiQGxdC+Rxhdb0e/FaQgehBO5raAxqrnC9pAFMRRj+8KPKlfsVSZGF L+S2xDlct3xthWESbox+xdcxpZ7Wixwff6s3s= Received: by 10.91.2.7 with SMTP id e7mr2453784agi.195.1313275003627; Sat, 13 Aug 2011 15:36:43 -0700 (PDT) Received: from a.local ([12.68.183.2]) by mx.google.com with ESMTPS id l2sm3749077anm.50.2011.08.13.15.36.40 (version=SSLv3 cipher=OTHER); Sat, 13 Aug 2011 15:36:41 -0700 (PDT) Message-ID: <4E46FC76.9090109@gmail.com> Date: Sat, 13 Aug 2011 15:36:38 -0700 From: Phil Steitz User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 To: Commons Users List Subject: Re: [dbcp] PoolingDataSource setup problem References: <4E439433.4000500@xlbit.com> <4E439475.2060903@sodomaco.it> In-Reply-To: <4E439475.2060903@sodomaco.it> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On 8/11/11 1:36 AM, Andrea Sodomaco wrote: > Hi, > > I tried to follow this example > http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/doc/PoolingDataSourceExample.java?view=markup > > > but at lines 148/149 > 148 PoolableConnectionFactory poolableConnectionFactory = > 149 new PoolableConnectionFactory(connectionFactory); > > it fails because, according to > http://commons.apache.org/dbcp/api-1.4/index.html > , all > constructors need an ObjectPool > but also all costructors of GenericObjectPool need a > PoolableObjectFactory! > > I "solved" the problem by this work-around > PoolableConnectionFactory poolableConnectionFactory = > new > PoolableConnectionFactory(connectionFactory,*new > GenericObjectPool()*,null,null,false,false); > > ObjectPool connectionPool = new > GenericObjectPool(poolableConnectionFactory); > poolableConnectionFactory.setPool(connectionPool); > > > that uses a "fake" GenericObjectPool. > I don't think this is the right solution. What I am missing? Sorry for the slow response. The example at the URL above is for the (still stabilizing) 2.0 version of DBCP. The funny setup that you have pointed out is being fixed in 2.0.. What you need to do in 1.x, is to follow the example here: http://svn.apache.org/viewvc/commons/proper/dbcp/tags/DBCP_1_4/doc/ManualPoolingDataSourceExample.java?revision=910071&view=markup To work around the circularity, the example creates a GenericObjectPool with a null factory and then passes the pool to the PoolableConnectionFactory constructor, which as a side effects calls the pool's setFactory method to associated it with the pool. Phil > > Thanks in advance. > Andrea > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org