Re: setPortNumber() should not be used when useing connection fail-over feature with PGConnectionPoolDataSource?

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: "Okano, Naoki" <okano(dot)naoki(at)jp(dot)fujitsu(dot)com>
Cc: "pgsql-jdbc(at)lists(dot)postgresql(dot)org" <pgsql-jdbc(at)lists(dot)postgresql(dot)org>
Subject: Re: setPortNumber() should not be used when useing connection fail-over feature with PGConnectionPoolDataSource?
Date: 2019-01-07 16:01:36
Message-ID: CADK3HHJ0EUmj6iPJdUW0zuad-xsraOv89QPENYAkhDjhgXgLig@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Pretty sure this was never intended to work.

That said if you can provide a pull request we can look at implementing it.

Dave Cramer

davec(at)postgresintl(dot)com
www.postgresintl.com

On Mon, 7 Jan 2019 at 05:07, Okano, Naoki <okano(dot)naoki(at)jp(dot)fujitsu(dot)com>
wrote:

> Hi,
>
> I want to use connection fail-over feature with
> PGConnectionPoolDataSource.
> (In this time, I does not use DriverManager.)
>
> When specifying multiple hosts for the serverName property
> and using setPortNumber() with PGConnectionPoolDataSource,
> it does not work well. Please show cases (2) and (3) below.
>
> So, when I use connection fail-over feature with
> PGConnectionPoolDataSource,
> I think setPortNumber() should not be used. Is my understanding correct?
>
> I show my environment and testing cases.
>
> [My environment]
> There are two hosts, host1 and host2.
> They have Postgres with port 5433 (not default port).
>
> [My test cases]
> case (1):
> Specifying host and port pairs for the serverName property,
> An example of code is as follows.
> PGConnectionPoolDataSource source = new PGConnectionPoolDataSource();
> source.setServerName("host1:5433,host2:5433");
> conn = source.getConnection();
> This works well. I can connect to both host1 and host2 correctly.
>
> case (2):
> Specifying multiple hosts for the serverName property and then
> specifying portNumber.
> An example of code is as follows.
> PGConnectionPoolDataSource source = new PGConnectionPoolDataSource();
> source.setServerName("host1,host2");
> source.setPortNumber(5433);
> conn = source.getConnection();
> This does not work well.
> Connection to host2 is succeeded, but conection to host1 always fails.
> In this case, source.getUrl() shows
> "jdbc:postgresql://host1,host2:5433...".
> I hope source.getUrl() shows
> "jdbc:postgresql://host1:5433,host2:5433...",
> but connection to host1 uses default port.
>
> case (3):
> Specify host and port pairs for the serverName property, and then
> Specify portNumber.
> An example of code is as follows.
> PGConnectionPoolDataSource source = new PGConnectionPoolDataSource();
> source.setServerName("host1:5433,host2:5433");
> source.setPortNumber(5433);
> conn = source.getConnection();
> This does not work well.
> Connection to host1 is succeeded, but conection to host2 fails.
> In this case, source.getUrl() shows
> "jdbc:postgresql://host1:5433,host2:5433:5433...".
> host2:5433:5433 is clearly wrong.
>
> Regards,
> Okano Naoki
>
>
>
>

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Okano, Naoki 2019-01-08 08:09:02 RE: setPortNumber() should not be used when useing connection fail-over feature with PGConnectionPoolDataSource?
Previous Message Craig Ringer 2019-01-07 13:45:21 [pgjdbc/pgjdbc] 72dc69: Update waffle-jna to new artifact coordinates (#13...