Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 73446 invoked from network); 2 Dec 2008 07:40:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Dec 2008 07:40:46 -0000 Received: (qmail 10208 invoked by uid 500); 2 Dec 2008 07:40:45 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 10154 invoked by uid 500); 2 Dec 2008 07:40:45 -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 10095 invoked by uid 99); 2 Dec 2008 07:40:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Dec 2008 23:40:45 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of newadminbg@gmail.com designates 209.85.219.13 as permitted sender) Received: from [209.85.219.13] (HELO mail-ew0-f13.google.com) (209.85.219.13) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Dec 2008 07:39:16 +0000 Received: by ewy6 with SMTP id 6so81979ewy.18 for ; Mon, 01 Dec 2008 23:40:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type; bh=+LGp+h2FAMKa77EySw5AqzZxK5M3rIuK3MEj9F/OLj8=; b=kQ/dNyH/CyMuE6oWn5mROTDWvmDX1/XGb0Bc4CcLvct/hC2NdSOoKqTofRFfRxNJCh x+kPa67K0mHq3Z4ZkHmA00jEvKUzGTBZ8TbTTDv5LVWB+XzBaiB05HhEWXWJdlMHh1+U UllOXxaQn2vEa84nnSqSj7OjLWk6xGgNszhXs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; b=xzCDUopKfcZ8Ei4gok4qCzPyMXPMZHdnyRQ5qEjNM4TMRFO8HSoVZcCa9ah7IXkcNL tDsEqluUSLrs3d5QNlGeLKt2/Zx1/zl+RC2DQ2DhEnSvt1BK6XYC0L8Wbn9sZpfIKwz6 I3r7KW9+m0u7lJZFuS/i0YGtbsUnW8edP1ezU= Received: by 10.210.59.14 with SMTP id h14mr13637557eba.182.1228203602595; Mon, 01 Dec 2008 23:40:02 -0800 (PST) Received: from ?192.168.1.7? ([77.77.2.159]) by mx.google.com with ESMTPS id d2sm6043212nfc.20.2008.12.01.23.39.59 (version=SSLv3 cipher=RC4-MD5); Mon, 01 Dec 2008 23:40:01 -0800 (PST) Message-ID: <4934E777.8000109@gmail.com> Date: Tue, 02 Dec 2008 09:44:55 +0200 From: Martin Dyulgerov User-Agent: Thunderbird 2.0.0.12 (X11/20080213) MIME-Version: 1.0 To: Commons Users List Subject: Re: DBCP problem with idle object References: <49341C36.5090607@gmail.com> <4934960F.5030406@gmail.com> In-Reply-To: <4934960F.5030406@gmail.com> Content-Type: multipart/mixed; boundary="------------030905040006090104000101" X-Virus-Checked: Checked by ClamAV on apache.org --------------030905040006090104000101 Content-Type: text/plain; charset=windows-1251; format=flowed Content-Transfer-Encoding: 7bit Thank you Phil! I see the logic in your reply. I'll try those suggestions, first thing today. I'll remove the following setting from my file: config.minIdle=5; config.timeBetweenEvictionRunsMillis=1000; config.minEvictableIdleTimeMillis=1000; Hope it works! Best regards, Martin Phil Steitz wrote: > Martin Dyulgerov wrote: >> Hello group! >> >> This is the first time i actuali write something in here. First of >> all - please excuse my bad english, it is not my native language. Now >> to get to the point... I have problems implementing DBCP on my Tomcat >> 6.0.18 in my web applications. I don't want to use JNDI, that is why >> i have ServletContextListener, in witch i do as follows in order: >> >> 1.Define GenericObject Pool >> 2. Define ConnectionFactory as implementation of >> DriverManagerConnectionFactory >> 3.Define PoolableConnectionFactory with the previously created >> GenericObjectPool and ConnectionFactory >> 4.Define PoolingDataSource with the GenericObjectPool object from step 1 >> >> Then i "stick" my PoolingDataSource to the servlet context, retreive >> it in my JSPs and servlets and aquire a connection via >> "getConnection()" (which returns Connection object). I make sure to >> close() all my connections at the edn of the pages...I am sure that >> the connections that are opened dont exceed the number 100 (which is >> the maximum number of connections on my database - a MySQL database >> system), so i think there must be something wrong with my pooling >> code. The exact error i get is: >> >> "Exception: Cannot get a connection, pool error Timeout waiting for >> idle object SQL Exception Connection is closed. SQLException >> Connection is closed." At some point i began to ask myself if it the >> problem is caused by the restarts(reloads) i do for that exact >> application, because the other work fine (byt i dont play with them >> that much)... My configurations for the GenericObjectPool and >> DriverManagerConnectionFactory are as follows: >> >> GenericObjectPool.Config config=new GenericObjectPool.Config(); >> config.maxActive=15; >> config.maxIdle=10; >> config.minIdle=5; >> config.maxWait=3000; >> config.testOnBorrow=true; >> config.testOnReturn=true; >> config.testWhileIdle=true; >> config.timeBetweenEvictionRunsMillis=1000; >> config.minEvictableIdleTimeMillis=1000; >> >> Properties p=new Properties(); >> p.setProperty("user", user); >> p.setProperty("password", password); >> p.setProperty("useUnicode", "true"); >> p.setProperty("characterEncoding", "CP1251"); >> p.setProperty("autoReconnect", "true"); >> >> Can You help me please? Any help will be appriciated. Thanks in >> advance, and accept my apologies if i have breaked some rules of the >> group or something like that. > These settings make it hard for the pool to manage connections: > config.maxIdle=10; > config.minIdle=5; > config.timeBetweenEvictionRunsMillis=1000; > config.minEvictableIdleTimeMillis=1000; > > The first two force the pool to try to keep the number of idle > connections between 5 and 10, which is going to force it to close / > open frequently to stay within that relatively narrow range. Unless > you really need both of these, I would recommend eliminating one or > both of them. > > The second two are probably the source of your problem. These > parameters are specified in milliseconds (thousandths of a second). > The first one tells the pool to kick off an evictor run every second > and the second tells it to destroy any connections that sit idle for > more than a second. This will create lots of connection churn and > also pool access contention as the idle object evictor runs every > second and closes connections that have been idle and then tries to > create new ones to reach minIdle. You should either increase both of > these by at least an order of magnitude or drop them. Unless you > really want to close connections that have been idle in the pool for > longer than a specified idle timeout, I would drop these. > > Phil > > > > >> >> All best, >> >> Martin >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org >> For additional commands, e-mail: user-help@commons.apache.org >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org > For additional commands, e-mail: user-help@commons.apache.org > > --------------030905040006090104000101 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org --------------030905040006090104000101--