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 7B4511764B for ; Wed, 7 Oct 2015 22:23:04 +0000 (UTC) Received: (qmail 45914 invoked by uid 500); 7 Oct 2015 22:23:03 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 45795 invoked by uid 500); 7 Oct 2015 22:23:03 -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 45783 invoked by uid 99); 7 Oct 2015 22:23:03 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Oct 2015 22:23:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id DBAB6C03EF for ; Wed, 7 Oct 2015 22:23:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.121 X-Spam-Level: X-Spam-Status: No, score=-0.121 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 3D5lvEjRpSYT for ; Wed, 7 Oct 2015 22:23:02 +0000 (UTC) Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id 47938201F9 for ; Wed, 7 Oct 2015 22:23:01 +0000 (UTC) Received: by padhy16 with SMTP id hy16so33275369pad.1 for ; Wed, 07 Oct 2015 15:22:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=AAeFQKdA4cahfWbHZ4TDMa+YO2wL7as2gnRx97fQxbU=; b=crwgsizj3gZNLteCfbVe4AAI/TSl7SG4lbJh58uj2qnDog1EeG4aVZbEvXwEr9DzWm tkePFTXbCee8b7LjxsaaG4NzW/oZgVfGPhVIEUX2F/yksgumjUX7JYSTs8tE/3zQJ5z9 tiKFt34Z8KSv47TlUUgkj/K+uNvOoE3EPxD0VT5hIj+Gz3Geb3RJ4siCb93kS3te9Sfs ckeEznukuqIbClA0An76PJRKBVdquspYi7Fctk1kWR40eI3Uw5Hv71ovT0L/02104fyH U+PjKJFY4GBSxQOqgJ8q/nLEXX1Zr7pZJyt+aUDhcLt92zl4TQ+mhAwc4nJTkm4eZj7g C2MA== X-Received: by 10.68.168.226 with SMTP id zz2mr3861477pbb.8.1444256573910; Wed, 07 Oct 2015 15:22:53 -0700 (PDT) Received: from psteitz-mbp.local ([67.133.165.2]) by smtp.googlemail.com with ESMTPSA id fb1sm41504841pab.9.2015.10.07.15.22.52 for (version=TLSv1/SSLv3 cipher=OTHER); Wed, 07 Oct 2015 15:22:52 -0700 (PDT) Subject: Re: [dbcp] auto reconnecting To: Commons Users List References: From: Phil Steitz X-Enigmail-Draft-Status: N1110 Message-ID: <56159B3B.9050903@gmail.com> Date: Wed, 7 Oct 2015 15:22:51 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 10/7/15 12:35 PM, Pruitt, Byron S wrote: > My server has long standing idle periods. We are seeing: com.mysql.jd= bc.exceptions.jdbc4.CommunicationsException: The last packet successfully= received from the server was... errors. > > I would like to fix it as simply as possible. MySQL has two properties= autoReconnect and autoReconnectForPools that might fix the problem. The= y both default to false and I can't find an easy way to set them. > I had an earlier problem with auto commit and I fixed it with the setDe= faultAutoCommit method on PoolableConnectionFactory. But, it doesn't hav= e a similar setter for auto reconnect. > > The only example I found of setting the autoReconnect property is on th= e connection url. I use the interface where I pass an instance of Proper= ties, so I assume I can set those properties with it. > > I am curious if there are better ways to set those properties. If you are using BasicDataSource, you can use it's addConnectionProperty method to add driver-specific connection properties such as this. Just make sure to add the property before you use the datasource. You can achieve the same effect by enabling validation on borrow or while idle (testOnBorrow, testWhileIdle). Phil > > Thanks. > > -SP > > --------------------------------------------------------------------- > 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