forked from pgjdbc/pgjdbc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use slightly different SQL State error codes for the different
types of connection setup failures to indicate which can be retried and which cannot. Per discussion with Donald Fraser and Kevin Grittner.
- Loading branch information
Showing
3 changed files
with
40 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* Copyright (c) 2004, Open Cloud Limited. | ||
* | ||
* IDENTIFICATION | ||
* $PostgreSQL: pgjdbc/org/postgresql/core/v2/ConnectionFactoryImpl.java,v 1.13 2007/10/08 01:49:59 jurka Exp $ | ||
* $PostgreSQL: pgjdbc/org/postgresql/core/v2/ConnectionFactoryImpl.java,v 1.14 2008/01/08 06:56:27 jurka Exp $ | ||
* | ||
*------------------------------------------------------------------------- | ||
*/ | ||
|
@@ -90,7 +90,7 @@ public ProtocolConnection openConnectionImpl(String host, int port, String user, | |
// Added by Peter Mount <[email protected]> | ||
// 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); | ||
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_UNABLE_TO_CONNECT, cex); | ||
} | ||
catch (IOException ioe) | ||
{ | ||
|
@@ -144,7 +144,7 @@ private PGStream enableSSL(PGStream pgStream, boolean requireSSL, Properties inf | |
|
||
// Server doesn't even know about the SSL handshake protocol | ||
if (requireSSL) | ||
throw new PSQLException(GT.tr("The server does not support SSL."), PSQLState.CONNECTION_FAILURE); | ||
throw new PSQLException(GT.tr("The server does not support SSL."), PSQLState.CONNECTION_REJECTED); | ||
|
||
// We have to reconnect to continue. | ||
pgStream.close(); | ||
|
@@ -156,7 +156,7 @@ private PGStream enableSSL(PGStream pgStream, boolean requireSSL, Properties inf | |
|
||
// Server does not support ssl | ||
if (requireSSL) | ||
throw new PSQLException(GT.tr("The server does not support SSL."), PSQLState.CONNECTION_FAILURE); | ||
throw new PSQLException(GT.tr("The server does not support SSL."), PSQLState.CONNECTION_REJECTED); | ||
|
||
return pgStream; | ||
|
||
|
@@ -169,7 +169,7 @@ private PGStream enableSSL(PGStream pgStream, boolean requireSSL, Properties inf | |
return pgStream; | ||
|
||
default: | ||
throw new PSQLException(GT.tr("An error occured while setting up the SSL connection."), PSQLState.CONNECTION_FAILURE); | ||
throw new PSQLException(GT.tr("An error occured while setting up the SSL connection."), PSQLState.PROTOCOL_VIOLATION); | ||
} | ||
} | ||
|
||
|
@@ -309,7 +309,7 @@ private void doAuthentication(PGStream pgStream, String user, String password, L | |
break; | ||
|
||
default: | ||
throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.CONNECTION_UNABLE_TO_CONNECT); | ||
throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.PROTOCOL_VIOLATION); | ||
} | ||
} | ||
} | ||
|
@@ -347,7 +347,7 @@ private void readStartupMessages(PGStream pgStream, ProtocolConnectionImpl proto | |
break; | ||
|
||
default: | ||
throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.CONNECTION_UNABLE_TO_CONNECT); | ||
throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.PROTOCOL_VIOLATION); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* Copyright (c) 2004, Open Cloud Limited. | ||
* | ||
* IDENTIFICATION | ||
* $PostgreSQL: pgjdbc/org/postgresql/core/v3/ConnectionFactoryImpl.java,v 1.14 2007/10/08 01:49:59 jurka Exp $ | ||
* $PostgreSQL: pgjdbc/org/postgresql/core/v3/ConnectionFactoryImpl.java,v 1.15 2008/01/08 06:56:27 jurka Exp $ | ||
* | ||
*------------------------------------------------------------------------- | ||
*/ | ||
|
@@ -120,7 +120,7 @@ public ProtocolConnection openConnectionImpl(String host, int port, String user, | |
// Added by Peter Mount <[email protected]> | ||
// 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); | ||
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_UNABLE_TO_CONNECT, cex); | ||
} | ||
catch (IOException ioe) | ||
{ | ||
|
@@ -172,7 +172,7 @@ private PGStream enableSSL(PGStream pgStream, boolean requireSSL, Properties inf | |
|
||
// Server doesn't even know about the SSL handshake protocol | ||
if (requireSSL) | ||
throw new PSQLException(GT.tr("The server does not support SSL."), PSQLState.CONNECTION_FAILURE); | ||
throw new PSQLException(GT.tr("The server does not support SSL."), PSQLState.CONNECTION_REJECTED); | ||
|
||
// We have to reconnect to continue. | ||
pgStream.close(); | ||
|
@@ -184,7 +184,7 @@ private PGStream enableSSL(PGStream pgStream, boolean requireSSL, Properties inf | |
|
||
// Server does not support ssl | ||
if (requireSSL) | ||
throw new PSQLException(GT.tr("The server does not support SSL."), PSQLState.CONNECTION_FAILURE); | ||
throw new PSQLException(GT.tr("The server does not support SSL."), PSQLState.CONNECTION_REJECTED); | ||
|
||
return pgStream; | ||
|
||
|
@@ -197,7 +197,7 @@ private PGStream enableSSL(PGStream pgStream, boolean requireSSL, Properties inf | |
return pgStream; | ||
|
||
default: | ||
throw new PSQLException(GT.tr("An error occured while setting up the SSL connection."), PSQLState.CONNECTION_FAILURE); | ||
throw new PSQLException(GT.tr("An error occured while setting up the SSL connection."), PSQLState.PROTOCOL_VIOLATION); | ||
} | ||
} | ||
|
||
|
@@ -379,7 +379,7 @@ private void doAuthentication(PGStream pgStream, String user, String password, L | |
break; | ||
|
||
default: | ||
throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.CONNECTION_UNABLE_TO_CONNECT); | ||
throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.PROTOCOL_VIOLATION); | ||
} | ||
} | ||
} | ||
|
@@ -422,7 +422,7 @@ private void readStartupMessages(PGStream pgStream, ProtocolConnectionImpl proto | |
// BackendKeyData | ||
int l_msgLen = pgStream.ReceiveInteger4(); | ||
if (l_msgLen != 12) | ||
throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.CONNECTION_UNABLE_TO_CONNECT); | ||
throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.PROTOCOL_VIOLATION); | ||
|
||
int pid = pgStream.ReceiveInteger4(); | ||
int ckey = pgStream.ReceiveInteger4(); | ||
|
@@ -468,7 +468,7 @@ private void readStartupMessages(PGStream pgStream, ProtocolConnectionImpl proto | |
else if (name.equals("client_encoding")) | ||
{ | ||
if (!value.equals("UNICODE")) | ||
throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.CONNECTION_UNABLE_TO_CONNECT); | ||
throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.PROTOCOL_VIOLATION); | ||
pgStream.setEncoding(Encoding.getDatabaseEncoding("UNICODE")); | ||
} | ||
else if (name.equals("standard_conforming_strings")) | ||
|
@@ -478,15 +478,15 @@ else if (name.equals("standard_conforming_strings")) | |
else if (value.equals("off")) | ||
protoConnection.setStandardConformingStrings(false); | ||
else | ||
throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.CONNECTION_UNABLE_TO_CONNECT); | ||
throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.PROTOCOL_VIOLATION); | ||
} | ||
|
||
break; | ||
|
||
default: | ||
if (logger.logDebug()) | ||
logger.debug("invalid message type=" + (char)beresp); | ||
throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.CONNECTION_UNABLE_TO_CONNECT); | ||
throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.PROTOCOL_VIOLATION); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters