Commit 1eb31d19 authored by Dave Cramer's avatar Dave Cramer

Here is a small patch that cleans up some error reporting in the JDBC driver....

Here is a small patch that cleans up some error reporting in the JDBC driver. PSQLExceptions are thrown instead of SQLExceptions and if a warning is received while waiting for the backend secret key, that warning is chained to the new Connection object instead of generating an exception. A couple new error messages have been added.
parent fdcb8516
...@@ -11,7 +11,7 @@ import org.postgresql.util.*; ...@@ -11,7 +11,7 @@ import org.postgresql.util.*;
import org.postgresql.core.*; import org.postgresql.core.*;
/* /*
* $Id: Connection.java,v 1.42 2002/03/05 18:00:36 davec Exp $ * $Id: Connection.java,v 1.43 2002/03/09 17:08:39 davec Exp $
* *
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or * This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class. * JDBC2 versions of the Connection class.
...@@ -139,6 +139,8 @@ public abstract class Connection ...@@ -139,6 +139,8 @@ public abstract class Connection
*/ */
protected void openConnection(String host, int port, Properties info, String database, String url, Driver d) throws SQLException protected void openConnection(String host, int port, Properties info, String database, String url, Driver d) throws SQLException
{ {
firstWarning = null;
// Throw an exception if the user or password properties are missing // Throw an exception if the user or password properties are missing
// This occasionally occurs when the client uses the properties version // This occasionally occurs when the client uses the properties version
// of getConnection(), and is a common question on the email lists // of getConnection(), and is a common question on the email lists
...@@ -209,7 +211,7 @@ public abstract class Connection ...@@ -209,7 +211,7 @@ public abstract class Connection
// The most common one to be thrown here is: // The most common one to be thrown here is:
// "User authentication failed" // "User authentication failed"
// //
throw new SQLException(pg_stream.ReceiveString(encoding)); throw new PSQLException("postgresql.con.misc", pg_stream.ReceiveString(encoding));
case 'R': case 'R':
// Get the type of request // Get the type of request
...@@ -304,8 +306,10 @@ public abstract class Connection ...@@ -304,8 +306,10 @@ public abstract class Connection
ckey = pg_stream.ReceiveIntegerR(4); ckey = pg_stream.ReceiveIntegerR(4);
break; break;
case 'E': case 'E':
throw new PSQLException("postgresql.con.backend", pg_stream.ReceiveString(encoding));
case 'N': case 'N':
throw new SQLException(pg_stream.ReceiveString(encoding)); addWarning(pg_stream.ReceiveString(encoding));
break;
default: default:
throw new PSQLException("postgresql.con.setup"); throw new PSQLException("postgresql.con.setup");
} }
...@@ -317,14 +321,11 @@ public abstract class Connection ...@@ -317,14 +321,11 @@ public abstract class Connection
case 'Z': case 'Z':
break; break;
case 'E': case 'E':
case 'N': throw new PSQLException("postgresql.con.backend", pg_stream.ReceiveString(encoding));
throw new SQLException(pg_stream.ReceiveString(encoding));
default: default:
throw new PSQLException("postgresql.con.setup"); throw new PSQLException("postgresql.con.setup");
} }
firstWarning = null;
// "pg_encoding_to_char(1)" will return 'EUC_JP' for a backend compiled with multibyte, // "pg_encoding_to_char(1)" will return 'EUC_JP' for a backend compiled with multibyte,
// otherwise it's hardcoded to 'SQL_ASCII'. // otherwise it's hardcoded to 'SQL_ASCII'.
// If the backend doesn't know about multibyte we can't assume anything about the encoding // If the backend doesn't know about multibyte we can't assume anything about the encoding
...@@ -361,7 +362,6 @@ public abstract class Connection ...@@ -361,7 +362,6 @@ public abstract class Connection
initObjectTypes(); initObjectTypes();
// Mark the connection as ok, and cleanup // Mark the connection as ok, and cleanup
firstWarning = null;
PG_STATUS = CONNECTION_OK; PG_STATUS = CONNECTION_OK;
} }
......
...@@ -3,6 +3,7 @@ postgresql.arr.range:The array index is out of range. ...@@ -3,6 +3,7 @@ postgresql.arr.range:The array index is out of range.
postgresql.drv.version:An internal error has occured. Please recompile the driver. postgresql.drv.version:An internal error has occured. Please recompile the driver.
postgresql.con.auth:The authentication type {0} is not supported. Check that you have configured the pg_hba.conf file to include the client's IP address or Subnet, and that it is using an authentication scheme supported by the driver. postgresql.con.auth:The authentication type {0} is not supported. Check that you have configured the pg_hba.conf file to include the client's IP address or Subnet, and that it is using an authentication scheme supported by the driver.
postgresql.con.authfail:An error occured while getting the authentication request. postgresql.con.authfail:An error occured while getting the authentication request.
postgresql.con.backend:Backend start-up failed: {0}.
postgresql.con.call:Callable Statements are not supported at this time. postgresql.con.call:Callable Statements are not supported at this time.
postgresql.con.creobj:Failed to create object for {0} {1} postgresql.con.creobj:Failed to create object for {0} {1}
postgresql.con.failed:The connection attempt failed because {0} postgresql.con.failed:The connection attempt failed because {0}
...@@ -11,9 +12,10 @@ postgresql.con.garbled:Garbled data received. ...@@ -11,9 +12,10 @@ postgresql.con.garbled:Garbled data received.
postgresql.con.ioerror:An IO erro occured while sending to the backend - {0} postgresql.con.ioerror:An IO erro occured while sending to the backend - {0}
postgresql.con.kerb4:Kerberos 4 authentication is not supported by this driver. postgresql.con.kerb4:Kerberos 4 authentication is not supported by this driver.
postgresql.con.kerb5:Kerberos 5 authentication is not supported by this driver. postgresql.con.kerb5:Kerberos 5 authentication is not supported by this driver.
postgresql.con.misc:A connection error has occurred: {0}
postgresql.con.multres:Cannot handle multiple result groups. postgresql.con.multres:Cannot handle multiple result groups.
postgresql.con.pass:The password property is missing. It is mandatory. postgresql.con.pass:The password property is missing. It is mandatory.
postgresql.con.refused:Connection refused. Check that the hostname and port is correct, and that the postmaster is running with the -i flag, which enables TCP/IP networking. postgresql.con.refused:Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
postgresql.con.setup:Protocol error. Session setup failed. postgresql.con.setup:Protocol error. Session setup failed.
postgresql.con.strobj:The object could not be stored. Check that any tables required have already been created in the database. postgresql.con.strobj:The object could not be stored. Check that any tables required have already been created in the database.
postgresql.con.strobjex:Failed to store object - {0} postgresql.con.strobjex:Failed to store object - {0}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment