Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1eb31d1

Browse files
author
Dave Cramer
committed
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.
1 parentfdcb851 commit1eb31d1

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

‎src/interfaces/jdbc/org/postgresql/Connection.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
importorg.postgresql.core.*;
1212

1313
/*
14-
* $Id: Connection.java,v 1.42 2002/03/05 18:00:36 davec Exp $
14+
* $Id: Connection.java,v 1.43 2002/03/09 17:08:39 davec Exp $
1515
*
1616
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
1717
* JDBC2 versions of the Connection class.
@@ -139,6 +139,8 @@ public void cancelQuery() throws SQLException
139139
*/
140140
protectedvoidopenConnection(Stringhost,intport,Propertiesinfo,Stringdatabase,Stringurl,Driverd)throwsSQLException
141141
{
142+
firstWarning =null;
143+
142144
// Throw an exception if the user or password properties are missing
143145
// This occasionally occurs when the client uses the properties version
144146
// of getConnection(), and is a common question on the email lists
@@ -209,7 +211,7 @@ protected void openConnection(String host, int port, Properties info, String dat
209211
// The most common one to be thrown here is:
210212
// "User authentication failed"
211213
//
212-
thrownewSQLException(pg_stream.ReceiveString(encoding));
214+
thrownewPSQLException("postgresql.con.misc",pg_stream.ReceiveString(encoding));
213215

214216
case'R':
215217
// Get the type of request
@@ -304,8 +306,10 @@ protected void openConnection(String host, int port, Properties info, String dat
304306
ckey =pg_stream.ReceiveIntegerR(4);
305307
break;
306308
case'E':
309+
thrownewPSQLException("postgresql.con.backend",pg_stream.ReceiveString(encoding));
307310
case'N':
308-
thrownewSQLException(pg_stream.ReceiveString(encoding));
311+
addWarning(pg_stream.ReceiveString(encoding));
312+
break;
309313
default:
310314
thrownewPSQLException("postgresql.con.setup");
311315
}
@@ -317,14 +321,11 @@ protected void openConnection(String host, int port, Properties info, String dat
317321
case'Z':
318322
break;
319323
case'E':
320-
case'N':
321-
thrownewSQLException(pg_stream.ReceiveString(encoding));
324+
thrownewPSQLException("postgresql.con.backend",pg_stream.ReceiveString(encoding));
322325
default:
323326
thrownewPSQLException("postgresql.con.setup");
324327
}
325328

326-
firstWarning =null;
327-
328329
// "pg_encoding_to_char(1)" will return 'EUC_JP' for a backend compiled with multibyte,
329330
// otherwise it's hardcoded to 'SQL_ASCII'.
330331
// If the backend doesn't know about multibyte we can't assume anything about the encoding
@@ -361,7 +362,6 @@ protected void openConnection(String host, int port, Properties info, String dat
361362
initObjectTypes();
362363

363364
// Mark the connection as ok, and cleanup
364-
firstWarning =null;
365365
PG_STATUS =CONNECTION_OK;
366366
}
367367

‎src/interfaces/jdbc/org/postgresql/errors.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ postgresql.arr.range:The array index is out of range.
33
postgresql.drv.version:An internal error has occured. Please recompile the driver.
44
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.
55
postgresql.con.authfail:An error occured while getting the authentication request.
6+
postgresql.con.backend:Backend start-up failed: {0}.
67
postgresql.con.call:Callable Statements are not supported at this time.
78
postgresql.con.creobj:Failed to create object for {0} {1}
89
postgresql.con.failed:The connection attempt failed because {0}
@@ -11,9 +12,10 @@ postgresql.con.garbled:Garbled data received.
1112
postgresql.con.ioerror:An IO erro occured while sending to the backend - {0}
1213
postgresql.con.kerb4:Kerberos 4 authentication is not supported by this driver.
1314
postgresql.con.kerb5:Kerberos 5 authentication is not supported by this driver.
15+
postgresql.con.misc:A connection error has occurred: {0}
1416
postgresql.con.multres:Cannot handle multiple result groups.
1517
postgresql.con.pass:The password property is missing. It is mandatory.
16-
postgresql.con.refused:Connection refused. Check that the hostname and portis correct, and that the postmaster isrunning with the -i flag, which enablesTCP/IPnetworking.
18+
postgresql.con.refused:Connection refused. Check that the hostname and portare correct and that the postmaster isacceptingTCP/IPconnections.
1719
postgresql.con.setup:Protocol error. Session setup failed.
1820
postgresql.con.strobj:The object could not be stored. Check that any tables required have already been created in the database.
1921
postgresql.con.strobjex:Failed to store object - {0}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp