Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 53F7F1337B68 for ; Tue, 8 Mar 2011 12:27:41 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 83237-01 for ; Tue, 8 Mar 2011 16:27:33 +0000 (UTC) X-Greylist: delayed 00:23:28.567824 by SQLgrey-1.7.6 Received: from mail.cisx.com (mail.cisx.com [78.41.6.67]) by mail.postgresql.org (Postfix) with ESMTP id 55AAF1337B5D for ; Tue, 8 Mar 2011 12:27:33 -0400 (AST) Received: from DEVELOP1 ([192.168.100.50]) by mail.cisx.com (8.13.1/8.13.1) with SMTP id p28G3uRM000320 for ; Tue, 8 Mar 2011 16:04:02 GMT Message-ID: From: "Donald Fraser" To: "[JDBC]" Subject: Invalid PSQLState used in connection classes Date: Tue, 8 Mar 2011 16:03:56 -0000 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5843 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.296 tagged_above=-10 required=5 tests=BAYES_00=-1.9, STOX_REPLY_TYPE=0.439, STOX_REPLY_TYPE_WITHOUT_QUOTES=1.757 X-Spam-Level: X-Archive-Number: 201103/5 X-Sequence-Number: 21560 I have noted in the Java code; File: /org/postgresql/core/v3/ConnectionFactoryImpl.java Class: ConnectionFactoryImpl catch (ConnectException cex) { // Added by Peter Mount // 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); } 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