Index: org/postgresql/core/v2/ConnectionFactoryImpl.java =================================================================== RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/core/v2/ConnectionFactoryImpl.java,v retrieving revision 1.20 diff -c -r1.20 ConnectionFactoryImpl.java *** org/postgresql/core/v2/ConnectionFactoryImpl.java 25 Dec 2010 07:07:44 -0000 1.20 --- org/postgresql/core/v2/ConnectionFactoryImpl.java 19 Mar 2011 23:34:44 -0000 *************** *** 101,107 **** // 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); } catch (IOException ioe) { --- 101,107 ---- // 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_UNABLE_TO_CONNECT, cex); } catch (IOException ioe) { *************** *** 155,161 **** // 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); // We have to reconnect to continue. pgStream.close(); --- 155,161 ---- // 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_REJECTED); // We have to reconnect to continue. pgStream.close(); *************** *** 167,173 **** // Server does not support ssl if (requireSSL) ! throw new PSQLException(GT.tr("The server does not support SSL."), PSQLState.CONNECTION_FAILURE); return pgStream; --- 167,173 ---- // Server does not support ssl if (requireSSL) ! throw new PSQLException(GT.tr("The server does not support SSL."), PSQLState.CONNECTION_REJECTED); return pgStream; *************** *** 180,186 **** return pgStream; default: ! throw new PSQLException(GT.tr("An error occured while setting up the SSL connection."), PSQLState.CONNECTION_FAILURE); } } --- 180,186 ---- return pgStream; default: ! throw new PSQLException(GT.tr("An error occured while setting up the SSL connection."), PSQLState.PROTOCOL_VIOLATION); } } *************** *** 319,325 **** break; default: ! throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.CONNECTION_UNABLE_TO_CONNECT); } } } --- 319,325 ---- break; default: ! throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.PROTOCOL_VIOLATION); } } } *************** *** 357,363 **** break; default: ! throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.CONNECTION_UNABLE_TO_CONNECT); } } } --- 357,363 ---- break; default: ! throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.PROTOCOL_VIOLATION); } } } Index: org/postgresql/core/v3/ConnectionFactoryImpl.java =================================================================== RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/core/v3/ConnectionFactoryImpl.java,v retrieving revision 1.23 diff -c -r1.23 ConnectionFactoryImpl.java *** org/postgresql/core/v3/ConnectionFactoryImpl.java 25 Dec 2010 07:07:44 -0000 1.23 --- org/postgresql/core/v3/ConnectionFactoryImpl.java 19 Mar 2011 23:34:44 -0000 *************** *** 135,141 **** // 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); } catch (IOException ioe) { --- 135,141 ---- // 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_UNABLE_TO_CONNECT, cex); } catch (IOException ioe) { *************** *** 187,193 **** // 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); // We have to reconnect to continue. pgStream.close(); --- 187,193 ---- // 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_REJECTED); // We have to reconnect to continue. pgStream.close(); *************** *** 199,205 **** // Server does not support ssl if (requireSSL) ! throw new PSQLException(GT.tr("The server does not support SSL."), PSQLState.CONNECTION_FAILURE); return pgStream; --- 199,205 ---- // Server does not support ssl if (requireSSL) ! throw new PSQLException(GT.tr("The server does not support SSL."), PSQLState.CONNECTION_REJECTED); return pgStream; *************** *** 212,218 **** return pgStream; default: ! throw new PSQLException(GT.tr("An error occured while setting up the SSL connection."), PSQLState.CONNECTION_FAILURE); } } --- 212,218 ---- return pgStream; default: ! throw new PSQLException(GT.tr("An error occured while setting up the SSL connection."), PSQLState.PROTOCOL_VIOLATION); } } *************** *** 406,412 **** break; default: ! throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.CONNECTION_UNABLE_TO_CONNECT); } } } --- 406,412 ---- break; default: ! throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.PROTOCOL_VIOLATION); } } } *************** *** 449,455 **** // 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); int pid = pgStream.ReceiveInteger4(); int ckey = pgStream.ReceiveInteger4(); --- 449,455 ---- // BackendKeyData int l_msgLen = pgStream.ReceiveInteger4(); if (l_msgLen != 12) ! throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.PROTOCOL_VIOLATION); int pid = pgStream.ReceiveInteger4(); int ckey = pgStream.ReceiveInteger4(); *************** *** 495,501 **** 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); pgStream.setEncoding(Encoding.getDatabaseEncoding("UNICODE")); } else if (name.equals("standard_conforming_strings")) --- 495,501 ---- else if (name.equals("client_encoding")) { if (!value.equals("UNICODE")) ! 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")) *************** *** 505,511 **** else if (value.equals("off")) protoConnection.setStandardConformingStrings(false); else ! throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.CONNECTION_UNABLE_TO_CONNECT); } break; --- 505,511 ---- else if (value.equals("off")) protoConnection.setStandardConformingStrings(false); else ! throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.PROTOCOL_VIOLATION); } break; *************** *** 513,519 **** 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); } } } --- 513,519 ---- default: if (logger.logDebug()) logger.debug("invalid message type=" + (char)beresp); ! throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.PROTOCOL_VIOLATION); } } } Index: org/postgresql/util/PSQLState.java =================================================================== RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/util/PSQLState.java,v retrieving revision 1.13 diff -c -r1.13 PSQLState.java *** org/postgresql/util/PSQLState.java 8 Jan 2008 06:56:31 -0000 1.13 --- org/postgresql/util/PSQLState.java 19 Mar 2011 23:34:44 -0000 *************** *** 37,48 **** --- 37,70 ---- public final static PSQLState INVALID_PARAMETER_TYPE = new PSQLState("07006"); + /** + * We could establish a connection with the server for unknown reasons. + * Could be a network problem. + */ public final static PSQLState CONNECTION_UNABLE_TO_CONNECT = new PSQLState("08001"); + public final static PSQLState CONNECTION_DOES_NOT_EXIST = new PSQLState("08003"); + + /** + * The server rejected our connection attempt. Usually an authentication + * failure, but could be a configuration error like asking for a SSL + * connection with a server that wasn't built with SSL support. + */ public final static PSQLState CONNECTION_REJECTED = new PSQLState("08004"); + + /** + * After a connection has been established, it went bad. + */ public final static PSQLState CONNECTION_FAILURE = new PSQLState("08006"); public final static PSQLState CONNECTION_FAILURE_DURING_TRANSACTION = new PSQLState("08007"); + + /** + * The server sent us a response the driver was not prepared for and + * is either bizarre datastream corruption, a driver bug, or + * a protocol violation on the server's part. + */ public final static PSQLState PROTOCOL_VIOLATION = new PSQLState("08P01"); + public final static PSQLState COMMUNICATION_ERROR = new PSQLState("08S01"); public final static PSQLState NOT_IMPLEMENTED = new PSQLState("0A000");