Lists: | pgsql-jdbc |
---|
From: | "Donald Fraser" <postgres(at)kiwi-fraser(dot)net> |
---|---|
To: | "[JDBC]" <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Invalid PSQLState used in connection classes |
Date: | 2011-03-08 16:03:56 |
Message-ID: | CD183140E21E4179B9F1F5DD77EB4E2F@DEVELOP1 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
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(at)retep(dot)org(dot)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
From: | "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> |
---|---|
To: | "Donald Fraser" <postgres(at)kiwi-fraser(dot)net>, "[JDBC]" <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: Invalid PSQLState used in connection classes |
Date: | 2011-03-08 16:48:57 |
Message-ID: | 4D760999020000250003B603@gw.wicourts.gov |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
"Donald Fraser" <postgres(at)kiwi-fraser(dot)net> wrote:
> 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.
08001 - SQLCLIENT UNABLE TO ESTABLISH SQLCONNECTION
Sounds better for that sort of failure.
-Kevin
From: | Kris Jurka <books(at)ejurka(dot)com> |
---|---|
To: | Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov> |
Cc: | Donald Fraser <postgres(at)kiwi-fraser(dot)net>, "[JDBC]" <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: Invalid PSQLState used in connection classes |
Date: | 2011-03-19 23:47:31 |
Message-ID: | alpine.BSO.2.00.1103191936050.28447@leary.csoft.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
On Tue, 8 Mar 2011, Kevin Grittner wrote:
> "Donald Fraser" <postgres(at)kiwi-fraser(dot)net> wrote:
>
>> 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.
>
> 08001 - SQLCLIENT UNABLE TO ESTABLISH SQLCONNECTION
>
> Sounds better for that sort of failure.
>
Sounds reasonable to me. Looking at the error codes used during startup,
I think we should also make some other changes at the same time.
CONNECTION_UNABLE_TO_CONNECT -> PROTOCOL_VIOLATION
CONNECTION_FAILURE -> PROTOCOL_VIOLATION
when the driver receives an unknown message.
CONNECTION_FAILURE -> CONNECTION_REJECTED
when the server doesn't support SSL, but we need a SSL connection. I
think CONNECTION_FAILURE should only be used when something has gone wrong
after a connection has been established.
Patch attached.
Kris Jurka
Attachment | Content-Type | Size |
---|---|---|
connection-sqlstates.patch | text/plain | 12.7 KB |
From: | Kris Jurka <books(at)ejurka(dot)com> |
---|---|
To: | Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov> |
Cc: | Donald Fraser <postgres(at)kiwi-fraser(dot)net>, "[JDBC]" <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: Invalid PSQLState used in connection classes |
Date: | 2011-03-31 03:07:27 |
Message-ID: | alpine.BSO.2.00.1103302307080.364@leary.csoft.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
On Sat, 19 Mar 2011, Kris Jurka wrote:
>
> On Tue, 8 Mar 2011, Kevin Grittner wrote:
>
>> "Donald Fraser" <postgres(at)kiwi-fraser(dot)net> wrote:
>>
>>> 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.
>>
>> 08001 - SQLCLIENT UNABLE TO ESTABLISH SQLCONNECTION
>>
>> Sounds better for that sort of failure.
>>
>
> Sounds reasonable to me. Looking at the error codes used during startup, I
> think we should also make some other changes at the same time.
>
> CONNECTION_UNABLE_TO_CONNECT -> PROTOCOL_VIOLATION
> CONNECTION_FAILURE -> PROTOCOL_VIOLATION
> when the driver receives an unknown message.
>
> CONNECTION_FAILURE -> CONNECTION_REJECTED
> when the server doesn't support SSL, but we need a SSL connection. I think
> CONNECTION_FAILURE should only be used when something has gone wrong after a
> connection has been established.
>
> Patch attached.
>
Applied to CVS for 8.2+.
Kris Jurka