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 E4C0C116A1 for ; Thu, 7 Aug 2014 20:52:51 +0000 (UTC) Received: (qmail 1404 invoked by uid 500); 7 Aug 2014 20:52:51 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 1295 invoked by uid 500); 7 Aug 2014 20:52:51 -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 1282 invoked by uid 99); 7 Aug 2014 20:52:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Aug 2014 20:52:50 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of parthpatil@gmail.com designates 209.85.223.174 as permitted sender) Received: from [209.85.223.174] (HELO mail-ie0-f174.google.com) (209.85.223.174) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Aug 2014 20:52:47 +0000 Received: by mail-ie0-f174.google.com with SMTP id rp18so5409927iec.19 for ; Thu, 07 Aug 2014 13:52:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=AQNf8N+qoss0GGcOzT/Uwh1nBp9+sjk2weEUro8I3Eo=; b=K6Kg++GDWMRXLDQeFKChgMkeUmaFOlS3e8sYycOJ9NxUG/bcR+TKJNdedKHmMGby6X P27yHUcLEgQXZC9KSSRK7hulcVN8g67NQxa7049fcfxsmPuRWabHZfldLOVMr154qF34 O8tTsZcvtTU/B/UHD3S1mnArNE7663IvjYMgb7s40PFb4kt+4jxTP8Wrfyou+90mLqS0 IMNY4OswldZ5bS9WiKMOoIrW6rUqHqSoU1NuZfm+hVtdWy3v+WQ9EWMqLi0KLCio+24Q 0ZfRHoHwX8CqabI5jysKP1fgneMUFbs+rVV+YCzW7KPl/VpCdnhqFT2fuTtvEW/ChMBF WJWw== MIME-Version: 1.0 X-Received: by 10.50.66.197 with SMTP id h5mr93899igt.34.1407444742526; Thu, 07 Aug 2014 13:52:22 -0700 (PDT) Received: by 10.107.15.20 with HTTP; Thu, 7 Aug 2014 13:52:22 -0700 (PDT) In-Reply-To: <53E1E413.2050608@apache.org> References: <53E1E413.2050608@apache.org> Date: Thu, 7 Aug 2014 13:52:22 -0700 Message-ID: Subject: Re: [dbcp] How to create replication aware connection pool ? From: Parth Patil To: Commons Users List Content-Type: multipart/alternative; boundary=047d7bd6be0eeb5f8b05001043e2 X-Virus-Checked: Checked by ClamAV on apache.org --047d7bd6be0eeb5f8b05001043e2 Content-Type: text/plain; charset=UTF-8 Hi Mark, Thanks a lot. Setting validation query on BasicDataSource fixed the problem! ds.setValidationQuery("SELECT 1") On Wed, Aug 6, 2014 at 1:15 AM, Mark Thomas wrote: > On 06/08/2014 01:34, Parth Patil wrote: > > Hi Friends, > > I am using DBCP2 in my project and I am pleased with the performance of > the > > library. Though I am only able to provide a single mysql host in the > > connection string. What do I need to do inorder to make the DBCP > connection > > pool replication aware ? > > Write some code :). DBCP 2 is not replication aware. There was an > enhancement request for this [1] but I resolved it as WONTFIX on the > bases that: > > ...generally, failover requires some form of database replication and > databases that provide that tend to provide JDBC drivers that support > failover as well. > > > > I am going to use 1 master and 2 slaves in my > > setup. Am I correct in assuming that its possible to create connection > pool > > over several mysql hosts ? > > No, you are not correct. > > > I tried to use the replication aware mysql jdbc driver > > (com.mysql.jdbc.ReplicationDriver) > > That is the correct way to do this. > > > but that doesn't seem to work and I am > > getting an exception. Following is my test code > > > > > Following is the exception that I am getting : > > > > [error] (run-main-0) java.lang.AbstractMethodError: > > com.mysql.jdbc.ReplicationConnection.isValid(I)Z > > > > DBCP2 uses JDBC4 (Java 1.6) and that is a new method introduced in that > release. > > You can avoid the call to that method by setting a validation query for > your connection pool. For MySQL the following should work: > /* ping */ SELECT 1 > > > Mark > > [1] https://issues.apache.org/jira/browse/DBCP-393 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org > For additional commands, e-mail: user-help@commons.apache.org > > -- Best, Parth --047d7bd6be0eeb5f8b05001043e2--