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 B197A9C11 for ; Tue, 22 Nov 2011 20:55:55 +0000 (UTC) Received: (qmail 44562 invoked by uid 500); 22 Nov 2011 20:55:54 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 44478 invoked by uid 500); 22 Nov 2011 20:55:54 -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 44470 invoked by uid 99); 22 Nov 2011 20:55:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Nov 2011 20:55:54 +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 (nike.apache.org: domain of phil.steitz@gmail.com designates 209.85.210.171 as permitted sender) Received: from [209.85.210.171] (HELO mail-iy0-f171.google.com) (209.85.210.171) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Nov 2011 20:55:46 +0000 Received: by iaby12 with SMTP id y12so812186iab.30 for ; Tue, 22 Nov 2011 12:55:25 -0800 (PST) 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=2l5AJOz4xtVO3jzunyH2oc8iW3rZ/jl2dIb8jpzewxg=; b=o2tkLWqqe7HGobvqTH3uvMmOH1RiI9tShuZ+ewEDfCrJ8MPfr6gsahihzFI7tiHL5Z Y66DEwIk/VWTt1mFE4DJmyaf1B4zELlwZyMJ8TfHgRL7OmF1cSimx8+WW1KVMNDeeGKo p+Bh0OCYmwXW9eXU6U8D2mCS2yRy5LFu3Axwg= Received: by 10.50.213.6 with SMTP id no6mr26173124igc.51.1321995325607; Tue, 22 Nov 2011 12:55:25 -0800 (PST) Received: from [192.168.0.2] (71-223-172-13.phnx.qwest.net. [71.223.172.13]) by mx.google.com with ESMTPS id p16sm64046605ibk.6.2011.11.22.12.55.23 (version=SSLv3 cipher=OTHER); Tue, 22 Nov 2011 12:55:24 -0800 (PST) Message-ID: <4ECC0C3A.9090605@gmail.com> Date: Tue, 22 Nov 2011 13:55:22 -0700 From: Phil Steitz User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: Commons Users List Subject: Re: [dbcp] Connections not validated even with validation query and test on borrow References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On 11/22/11 1:45 PM, Neil Aggarwal wrote: > Hello: > > I have the following code in my app to get a connection > pool to a MySQL database: > > String dbUri = "jdbc:mysql://localhost:3306/mydb"; > ConnectionFactory connectionFactory = new > DriverManagerConnectionFactory(dbUri,user,password); > GenericObjectPool connectionPool = new GenericObjectPool(null); > connectionPool.setMinEvictableIdleTimeMillis(5*60*1000); > connectionPool.setTimeBetweenEvictionRunsMillis(15*60*1000); > new > PoolableConnectionFactory(connectionFactory,connectionPool,null,"select > 1",false,true); > > ((org.apache.commons.pool.impl.GenericObjectPool)connectionPool).setTestOnBo > rrow(true); > return new PoolingDataSource(connectionPool); > > I have a long running cron job that is giving me this error: > > The last packet sent successfully to the server was 41,120,156 milliseconds > ago. > is longer than the server configured value of 'wait_timeout'. You should > consider > either expiring and/or testing connection validity before use in your > application, > increasing the server configured values for client timeouts, or using the C > onnector/J connection property 'autoReconnect=true' to avoid this problem. > > So, it looks like the connection validation is not happening. > > Did I do something wrong in my code? The validation happens when the connection is borrowed from the pool, i.e., when your code requests a connection from the DataSource. If you code is holding onto the checked out connection for longer than the timeout, it will not be re-validated by DBCP. Is it possible that that is your problem? Phil > > Thanks, > Neil > > -- > Neil Aggarwal, (972)834-1565, http://UnmeteredVPS.net/centos > Virtual private server with CentOS 6 preinstalled > Unmetered bandwidth = no overage charges > > > --------------------------------------------------------------------- > 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