commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Parth Patil <parthpa...@gmail.com>
Subject Re: [dbcp] How to create replication aware connection pool ?
Date Thu, 07 Aug 2014 20:52:22 GMT
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 <markt@apache.org> 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:
> <quote>
> ...generally, failover requires some form of database replication and
> databases that provide that tend to provide JDBC drivers that support
> failover as well.
> </quote>
>
> > 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
>
> <snip/>
>
> > Following is the exception that I am getting :
> >
> > [error] (run-main-0) java.lang.AbstractMethodError:
> > com.mysql.jdbc.ReplicationConnection.isValid(I)Z
>
> <snip/>
>
> 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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message