pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Donald Fraser <postgres@kiwi-fraser.net>
To: [JDBC] <pgsql-jdbc@postgresql.org>
Subject: Invalid PSQLState used in connection classes
Date: Tue, 8 Mar 2011 16:03:56 -0000
Message-ID: <CD183140E21E4179B9F1F5DD77EB4E2F@DEVELOP1> (raw)

I have noted in the Java code;

File: /org/postgresql/core/v3/ConnectionFactoryImpl.java

Class: ConnectionFactoryImpl

<code snipit>
catch (ConnectException cex)
{
// Added by Peter Mount <peter@retep.org.uk>
// ConnectException is thrown when the connection cannot be made.
// we trap this an return a more meaningful message for the end user
throw new PSQLException (GT.tr("Connection refused. Check that the hostname 
and port are correct and that the postmaster is accepting TCP/IP 
connections."), PSQLState.CONNECTION_REJECTED, cex);
}
</code snipit>

that the use of PSQLState.CONNECTION_REJECTED (08004) is incorrect.
According to the documentation, a CONNECTION_REJECTED error means that the 
PostgreSQL server has rejected the connection.
However if I have a broken network between my client and the server, such 
that there is no route to the server, I can get a ConnectException and I 
have not established, in any way, a connection to the PostgreSQL server.

Why am I complaining about it?
For automation purposes where the client automatically reconnects when a 
broken connection is detected we do not want to keep retrying when we get a 
CONNECTION_REJECTED from the PostgreSQL server. Because this is meant to 
indicate that there is something wrong with our credentials, permissions or 
other settings on the server (e.g. pg_hba.conf).
Remote networks over the Internet can often go down and we would like our 
automated systems to re-establish such connections, but we can't if the 
driver reports CONNECTION_REJECTED for conditions that are not true.

Regards
Donald Fraser 




view thread (4+ messages)  latest in thread

Message-ID: <CD183140E21E4179B9F1F5DD77EB4E2F@DEVELOP1>
Permalink:  ../CD183140E21E4179B9F1F5DD77EB4E2F@DEVELOP1/
Also on:    postgresql.org/message-id/CD183140E21E4179B9F1F5DD77EB4E2F@DEVELOP1

 · 

reply

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-jdbc@postgresql.org
  Cc: postgres@kiwi-fraser.net
  Subject: Re: Invalid PSQLState used in connection classes
  In-Reply-To: <CD183140E21E4179B9F1F5DD77EB4E2F@DEVELOP1>
  References: <CD183140E21E4179B9F1F5DD77EB4E2F@DEVELOP1>

* 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