From: Adrian Klaver <adrian.klaver@aklaver.com>
To: chris <chrisk@pgsqlrocket.com>
To: Postgres General <pgsql-general@postgresql.org>
Subject: Re: JDBC connectivity issue
Date: Thu, 8 Mar 2018 13:24:59 -0800
Message-ID: <0175e71d-aa4f-1b9c-6a63-53b2a9dcbd9a@aklaver.com> (raw)
In-Reply-To: <fde5b685-6820-daa6-de4a-b94d16ba39c5@pgsqlrocket.com>
References: <fde5b685-6820-daa6-de4a-b94d16ba39c5@pgsqlrocket.com>
On 03/08/2018 01:12 PM, chris wrote:
> Hi,
>
> I have a JDBC temping to connect to 2 postgres nodes in a hot standby
> configuration. Running postgres 9.4 on centos6.
>
> What we are trying to accomplish is in an event of a failover, to first
> try to connect to the master. If that fails to then reach out to the
> standby.
>
> I looked online and found the suggested way to do this, but it's not
> working.
>
> This is the JDBC line we have:
>
> /jdbc.url=jdbc:postgresql://10.16.10.12:5432,10.16.10.13:5432/app_db/
That seems to be correct:
https://jdbc.postgresql.org/documentation/94/connect.html
"Connection Fail-over
To support simple connection fail-over it is possible to define multiple
endpoints (host and port pairs) in the connection url separated by
commas. The driver will try to once connect to each of them in order
until the connection succeeds. If none succeed, a normal connection
exception is thrown.
The syntax for the connection url is:
jdbc:postgresql://host1:port1,host2:port2/database"
>
> Here is the error we are getting:/
> /
>
> /2018-03-07 13:54:36, 994 ERROR:com.zaxxer.hikari.util.PropertyElf -
> failed to set properly port number on target class
> org.postgresql.ds.PGSimpleDataSource java.langNumberFormatException:for
> input string: "5432,10.16.10.13:5432"/
>
> It looks like the first IP address has disappeared or is not set right./
To me it looks whatever code you are using is trying to us
"5432,10.16.10.13:5432" as the port number for 10.16.10.12. In other
words it is not seeing the ',' as a separator for the two IP's'.
Can you provide more information about the JDBC version you are using
and the app code you are using?
> /
>
> Thanks in advance for the help.
>
>
> //
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, chrisk@pgsqlrocket.com
Subject: Re: JDBC connectivity issue
In-Reply-To: <0175e71d-aa4f-1b9c-6a63-53b2a9dcbd9a@aklaver.com>
References: <fde5b685-6820-daa6-de4a-b94d16ba39c5@pgsqlrocket.com> <0175e71d-aa4f-1b9c-6a63-53b2a9dcbd9a@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox