Re: setPortNumber() should not be used when useing connection fail-over feature with PGConnectionPoolDataSource?
Dave Cramer <[email protected]> Mon, 7 Jan 2019 11:01:36 -0500
| Newsgroups | gmane.comp.db.postgresql.jdbc |
|---|---|
| Message-ID | <CADK3HHJ0EUmj6iPJdUW0zuad-xsraOv89QPENYAkhDjhgXgLig@mail.gmail.com> |
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 [email protected] www.postgresintl.com On Mon, 7 Jan 2019 at 05:07, Okano, Naoki <[email protected]> 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 > > > >