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

Commit4c63b25

Browse files
author
Peter Mount
committed
Internationalisation of error messages
1 parentc2f0d56 commit4c63b25

27 files changed

+198
-132
lines changed

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

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
importpostgresql.util.*;
1111

1212
/**
13-
* $Id: Connection.java,v 1.16 1999/05/17 22:43:23 peter Exp $
13+
* $Id: Connection.java,v 1.17 1999/05/18 23:17:15 peter Exp $
1414
*
1515
* This abstract class is used by postgresql.Driver to open either the JDBC1 or
1616
* JDBC2 versions of the Connection class.
@@ -95,9 +95,9 @@ protected void openConnection(String host, int port, Properties info, String dat
9595
// This occasionally occurs when the client uses the properties version
9696
// of getConnection(), and is a common question on the email lists
9797
if(info.getProperty("user")==null)
98-
thrownewSQLException("The user property is missing. It is mandatory.");
98+
thrownewPSQLException("postgresql.con.user");
9999
if(info.getProperty("password")==null)
100-
thrownewSQLException("The password property is missing. It is mandatory.");
100+
thrownewPSQLException("postgresql.con.pass");
101101

102102
this_driver =d;
103103
this_url =newString(url);
@@ -116,9 +116,9 @@ protected void openConnection(String host, int port, Properties info, String dat
116116
// Added by Peter Mount <peter@retep.org.uk>
117117
// ConnectException is thrown when the connection cannot be made.
118118
// we trap this an return a more meaningful message for the end user
119-
thrownewSQLException ("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.");
119+
thrownewPSQLException ("postgresql.con.refused");
120120
}catch (IOExceptione) {
121-
thrownewSQLException ("Connectionfailed: " +e.toString());
121+
thrownewPSQLException ("postgresql.con.failed",e);
122122
}
123123

124124
// Now we need to construct and send a startup packet
@@ -173,11 +173,11 @@ protected void openConnection(String host, int port, Properties info, String dat
173173

174174
caseAUTH_REQ_KRB4:
175175
DriverManager.println("postgresql: KRB4");
176-
thrownewSQLException("Kerberos 4 not supported");
176+
thrownewPSQLException("postgresql.con.kerb4");
177177

178178
caseAUTH_REQ_KRB5:
179179
DriverManager.println("postgresql: KRB5");
180-
thrownewSQLException("Kerberos 5 not supported");
180+
thrownewPSQLException("postgresql.con.kerb5");
181181

182182
caseAUTH_REQ_PASSWORD:
183183
DriverManager.println("postgresql: PASSWORD");
@@ -197,17 +197,17 @@ protected void openConnection(String host, int port, Properties info, String dat
197197
break;
198198

199199
default:
200-
thrownewSQLException("Authentication type "+areq+" not supported. Check that you have configured the pg_hba.conf file to include the client's IP address or Subnet, and is using a supported authentication scheme.");
200+
thrownewPSQLException("postgresql.con.auth",newInteger(areq));
201201
}
202202
break;
203203

204204
default:
205-
thrownewSQLException("error getting authentication request");
205+
thrownewPSQLException("postgresql.con.authfail");
206206
}
207207
}while(areq !=AUTH_REQ_OK);
208208

209209
}catch (IOExceptione) {
210-
thrownewSQLException("Connectionfailed: " +e.toString());
210+
thrownewPSQLException("postgresql.con.failed",e);
211211
}
212212

213213
// Originally we issued a SHOW DATESTYLE statement to find the databases default
@@ -290,7 +290,7 @@ public java.sql.ResultSet ExecSQL(String sql) throws SQLException
290290
SQLExceptionfinal_error =null;
291291

292292
if (sql.length() >8192)
293-
thrownewSQLException("SQL Statement too long: " +sql);
293+
thrownewPSQLException("postgresql.con.toolong",sql);
294294
try
295295
{
296296
pg_stream.SendChar('Q');
@@ -299,7 +299,7 @@ public java.sql.ResultSet ExecSQL(String sql) throws SQLException
299299
pg_stream.SendChar(0);
300300
pg_stream.flush();
301301
}catch (IOExceptione) {
302-
thrownewSQLException("I/O Error: " +e.toString());
302+
thrownewPSQLException("postgresql.con.ioerror",e);
303303
}
304304

305305
while (!hfr ||fqp >0)
@@ -316,7 +316,7 @@ public java.sql.ResultSet ExecSQL(String sql) throws SQLException
316316
break;
317317
case'B':// Binary Data Transfer
318318
if (fields ==null)
319-
thrownewSQLException("Tuple received before MetaData");
319+
thrownewPSQLException("postgresql.con.tuple");
320320
tup =pg_stream.ReceiveTuple(fields.length,true);
321321
// This implements Statement.setMaxRows()
322322
if(maxrows==0 ||tuples.size()<maxrows)
@@ -330,7 +330,7 @@ public java.sql.ResultSet ExecSQL(String sql) throws SQLException
330330
try {
331331
update_count =Integer.parseInt(recv_status.substring(1+recv_status.lastIndexOf(' ')));
332332
}catch(NumberFormatExceptionnfe) {
333-
thrownewSQLException("Unable tofathom update count\""+recv_status+"\"");
333+
thrownewPSQLException("postgresql.con.fathom",recv_status);
334334
}
335335
}
336336
if (fields !=null)
@@ -344,14 +344,14 @@ public java.sql.ResultSet ExecSQL(String sql) throws SQLException
344344
pg_stream.SendChar(0);
345345
pg_stream.flush();
346346
}catch (IOExceptione) {
347-
thrownewSQLException("I/O Error: " +e.toString());
347+
thrownewPSQLException("postgresql.con.ioerror",e);
348348
}
349349
fqp++;
350350
}
351351
break;
352352
case'D':// Text Data Transfer
353353
if (fields ==null)
354-
thrownewSQLException("Tuple received before MetaData");
354+
thrownewPSQLException("postgresql.con.tuple");
355355
tup =pg_stream.ReceiveTuple(fields.length,false);
356356
// This implements Statement.setMaxRows()
357357
if(maxrows==0 ||tuples.size()<maxrows)
@@ -366,7 +366,7 @@ public java.sql.ResultSet ExecSQL(String sql) throws SQLException
366366
intt =pg_stream.ReceiveChar();
367367

368368
if (t !=0)
369-
thrownewSQLException("Garbled Data");
369+
thrownewPSQLException("postgresql.con.garbled");
370370
if (fqp >0)
371371
fqp--;
372372
if (fqp ==0)
@@ -380,11 +380,11 @@ public java.sql.ResultSet ExecSQL(String sql) throws SQLException
380380
break;
381381
case'T':// MetaData Field Description
382382
if (fields !=null)
383-
thrownewSQLException("Cannot handle multiple result groups");
383+
thrownewPSQLException("postgresql.con.multres");
384384
fields =ReceiveFields();
385385
break;
386386
default:
387-
thrownewSQLException("Unknown Response Type: " + (char)c);
387+
thrownewPSQLException("postgresql.con.type",newCharacter((char)c));
388388
}
389389
}
390390
if (final_error !=null)
@@ -587,7 +587,7 @@ public Object getObject(String type,String value) throws SQLException
587587
sx.fillInStackTrace();
588588
throwsx;
589589
}catch(Exceptionex) {
590-
thrownewSQLException("Failed to create object for "+type+": "+ex);
590+
thrownewPSQLException("postgresql.con.creobj",type,ex);
591591
}
592592

593593
// should never be reached
@@ -622,14 +622,14 @@ public int putObject(Object o) throws SQLException
622622
return ((Serialize)x).store(o);
623623

624624
// Thow an exception because the type is unknown
625-
thrownewSQLException("The object could not be stored. Check that any tables required have already been created in the database.");
625+
thrownewPSQLException("postgresql.con.strobj");
626626

627627
}catch(SQLExceptionsx) {
628628
// rethrow the exception. Done because we capture any others next
629629
sx.fillInStackTrace();
630630
throwsx;
631631
}catch(Exceptionex) {
632-
thrownewSQLException("Failed to store object: "+ex);
632+
thrownewPSQLException("postgresql.con.strobjex",ex);
633633
}
634634
}
635635

‎src/interfaces/jdbc/postgresql/Driver.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
importjava.sql.*;
44
importjava.util.*;
55

6-
// You will find some mentions to a PSQLException class. This was intended
7-
// to allow internationalisation of error messages. However, this is not
8-
// working quite to plan, so the class exists in the source, but it's not
9-
// quite implemented yet. Peter May 17 1999.
10-
//
116
importpostgresql.util.PSQLException;
127

138
/**
@@ -109,10 +104,8 @@ public java.sql.Connection connect(String url, Properties info) throws SQLExcept
109104
return (java.sql.Connection)con;
110105
}catch(ClassNotFoundExceptionex) {
111106
thrownewPSQLException("postgresql.jvm.version",ex);
112-
//throw new SQLException("The postgresql.jar file does not contain the correct JDBC classes for this JVM. Try rebuilding.\nException thrown was "+ex.toString());
113107
}catch(Exceptionex2) {
114108
thrownewPSQLException("postgresql.unusual",ex2);
115-
//throw new SQLException("Something unusual has occured to cause the driver to fail. Please report this exception: "+ex2.toString());
116109
}
117110
// The old call - remove before posting
118111
//return new Connection (host(), port(), props, database(), url, this);
@@ -356,7 +349,6 @@ public String property(String name)
356349
publicstaticSQLExceptionnotImplemented()
357350
{
358351
returnnewPSQLException("postgresql.unimplemented");
359-
//return new SQLException("This method is not yet implemented.");
360352
}
361353
}
362354

‎src/interfaces/jdbc/postgresql/Field.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
importjava.sql.*;
55
importjava.util.*;
66
importpostgresql.*;
7+
importpostgresql.util.*;
78

89
/**
910
* postgresql.Field is a class used to describe fields in a PostgreSQL
@@ -62,7 +63,7 @@ public int getSQLType() throws SQLException
6263
if(type_name==null) {
6364
ResultSetresult = (postgresql.ResultSet)conn.ExecSQL("select typname from pg_type where oid = " +oid);
6465
if (result.getColumnCount() !=1 ||result.getTupleCount() !=1)
65-
thrownewSQLException("Unexpected return from query for type");
66+
thrownewPSQLException("postgresql.unexpected");
6667
result.next();
6768
type_name =result.getString(1);
6869
conn.fieldCache.put(newInteger(oid),type_name);

‎src/interfaces/jdbc/postgresql/PG_Stream.java

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
importjava.util.*;
77
importjava.sql.*;
88
importpostgresql.*;
9+
importpostgresql.util.*;
910

1011
/**
1112
* @version 1.0 15-APR-1997
@@ -22,15 +23,6 @@ public class PG_Stream
2223
privateInputStreampg_input;
2324
privateBufferedOutputStreampg_output;
2425

25-
// This is the error message returned when an EOF occurs
26-
privatestaticfinalStringEOF_MSG ="The backend has broken the connection. Possibly the action you have attempted has caused it to close.";
27-
28-
// This is the error message returned when an IOException occurs
29-
privatestaticfinalStringIOE_MSG ="IOError while reading from backend: ";
30-
31-
// This is the error message returned when flushing the stream.
32-
privatestaticfinalStringFLUSH_MSG ="Error flushing output: ";
33-
3426
/**
3527
* Constructor: Connect to the PostgreSQL back end and return
3628
* a stream connection.
@@ -178,9 +170,9 @@ public int ReceiveChar() throws SQLException
178170
try
179171
{
180172
c =pg_input.read();
181-
if (c <0)thrownewIOException(EOF_MSG);
173+
if (c <0)thrownewPSQLException("postgresql.stream.eof");
182174
}catch (IOExceptione) {
183-
thrownewSQLException(IOE_MSG +e.toString());
175+
thrownewPSQLException("postgresql.stream.ioerror",e);
184176
}
185177
returnc;
186178
}
@@ -203,11 +195,11 @@ public int ReceiveInteger(int siz) throws SQLException
203195
intb =pg_input.read();
204196

205197
if (b <0)
206-
thrownewIOException(EOF_MSG);
198+
thrownewPSQLException("postgresql.stream.eof");
207199
n =n | (b << (8 *i)) ;
208200
}
209201
}catch (IOExceptione) {
210-
thrownewSQLException(IOE_MSG +e.toString());
202+
thrownewPSQLException("postgresql.stream.ioerror",e);
211203
}
212204
returnn;
213205
}
@@ -230,11 +222,11 @@ public int ReceiveIntegerR(int siz) throws SQLException
230222
intb =pg_input.read();
231223

232224
if (b <0)
233-
thrownewIOException(EOF_MSG);
225+
thrownewPSQLException("postgresql.stream.eof");
234226
n =b | (n <<8);
235227
}
236228
}catch (IOExceptione) {
237-
thrownewSQLException(IOE_MSG +e.toString());
229+
thrownewPSQLException("postgresql.stream.ioerror",e);
238230
}
239231
returnn;
240232
}
@@ -259,16 +251,16 @@ public String ReceiveString(int maxsiz) throws SQLException
259251
{
260252
intc =pg_input.read();
261253
if (c <0)
262-
thrownewIOException(EOF_MSG);
254+
thrownewPSQLException("postgresql.stream.eof");
263255
elseif (c ==0)
264256
break;
265257
else
266258
rst[s++] = (byte)c;
267259
}
268260
if (s >=maxsiz)
269-
thrownewIOException("Too Much Data");
261+
thrownewPSQLException("postgresql.stream.toomuch");
270262
}catch (IOExceptione) {
271-
thrownewSQLException(IOE_MSG +e.toString());
263+
thrownewPSQLException("postgresql.stream.ioerror",e);
272264
}
273265
Stringv =newString(rst,0,s);
274266
returnv;
@@ -349,11 +341,11 @@ public void Receive(byte[] b,int off,int siz) throws SQLException
349341
{
350342
intw =pg_input.read(b,off+s,siz -s);
351343
if (w <0)
352-
thrownewIOException(EOF_MSG);
344+
thrownewPSQLException("postgresql.stream.eof");
353345
s +=w;
354346
}
355347
}catch (IOExceptione) {
356-
thrownewSQLException(IOE_MSG +e.toString());
348+
thrownewPSQLException("postgresql.stream.ioerror",e);
357349
}
358350
}
359351

@@ -367,7 +359,7 @@ public void flush() throws SQLException
367359
try {
368360
pg_output.flush();
369361
}catch (IOExceptione) {
370-
thrownewSQLException(FLUSH_MSG +e.toString());
362+
thrownewPSQLException("postgresql.stream.flush",e);
371363
}
372364
}
373365

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,67 @@
11
# This is the default errors
2+
postgresql.con.auth:The authentication type {1} 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.
3+
postgresql.con.authfail:An error occured while getting the authentication request.
4+
postgresql.con.call:Callable Statements are not supported at this time.
5+
postgresql.con.creobj:Failed to create object for {1} {2}
6+
postgresql.con.failed:The connection attempt failed because {1}
7+
postgresql.con.fathom:Unable to fathom update count {1}
8+
postgresql.con.garbled:Garbled data received.
9+
postgresql.con.ioerror:An IO erro occured while sending to the backend - {1}
10+
postgresql.con.kerb4:Kerberos 4 authentication is not supported by this driver.
11+
postgresql.con.kerb5:Kerberos 5 authentication is not supported by this driver.
12+
postgresql.con.multres:Cannot handle multiple result groups.
13+
postgresql.con.pass:The password property is missing. It is mandatory.
14+
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.
15+
postgresql.con.strobj:The object could not be stored. Check that any tables required have already been created in the database.
16+
postgresql.con.strobjex:Failed to store object - {1}
17+
postgresql.con.toolong:The SQL Statement is too long - {1}
18+
postgresql.con.tuple:Tuple received before MetaData.
19+
postgresql.con.type:Unknown Response Type {1}
20+
postgresql.con.user:The user property is missing. It is mandatory.
21+
postgresql.fp.error:FastPath call returned {1}
22+
postgresql.fp.expint:Fastpath call {1} - No result was returned and we expected an integer.
23+
postgresql.fp.protocol:FastPath protocol error: {1}
24+
postgresql.fp.send:Failed to send fastpath call {1} {2}
25+
postgresql.fp.unknown:The fastpath function {1} is unknown.
26+
postgresql.geo.box:Conversion of box failed - {1}
27+
postgresql.geo.circle:Conversion of circle failed - {1}
28+
postgresql.geo.line:Conversion of line failed - {1}
29+
postgresql.geo.lseg:Conversion of lseg failed - {1}
30+
postgresql.geo.path:Cannot tell if path is open or closed.
31+
postgresql.geo.point:Conversion of point failed - {1}
232
postgresql.jvm.version:The postgresql.jar file does not contain the correct JDBC classes for this JVM. Try rebuilding.\nException thrown was {1}
33+
postgresql.lo.init:failed to initialise LargeObject API
34+
postgresql.money:conversion of money failed - {1}.
35+
postgresql.prep.is:InputStream as parameter not supported
36+
postgresql.prep.param:No value specified for parameter {1}.
37+
postgresql.prep.range:Parameter index out of range.
38+
postgresql.prep.type:Unknown Types value.
39+
postgresql.res.badbigdec:Bad BigDecimal {1}
40+
postgresql.res.badbyte:Bad Byte {1}
41+
postgresql.res.baddate:Bad Date Format at {1} in {2}
42+
postgresql.res.baddouble:Bad Double {1}
43+
postgresql.res.badfloat:Bad Float {1}
44+
postgresql.res.badint:Bad Integer {1}
45+
postgresql.res.badlong:Bad Long {1}
46+
postgresql.res.badshort:Bad Short {1}
47+
postgresql.res.badtime:Bad Time {1}
48+
postgresql.res.badtimestamp:Bad Timestamp Format at {1} in {2}
49+
postgresql.res.colname:The column name {1} not found.
50+
postgresql.res.colrange:The column index is out of range.
51+
postgresql.serial.interface:You cannot serialize an interface.
52+
postgresql.serial.namelength:Class & Package name length cannot be longer than 32 characters. {1} is {2} characters.
53+
postgresql.serial.noclass:No class found for {1}.
54+
postgresql.serial.table:The table for {1} is not in the database. Contact the DBA, as the database is in an inconsistent state.
55+
postgresql.serial.underscore:Class names may not have _ in them. You supplied {1}.
56+
postgresql.stat.batch.empty:The batch is empty. There is nothing to execute.
57+
postgresql.stat.batch.error:Batch entry {1} {2} was aborted.
58+
postgresql.stat.maxfieldsize:An attempt to setMaxFieldSize() failed - compile time default in force.
59+
postgresql.stat.noresult:No results were returned by the query.
60+
postgresql.stat.result:A result was returned by the statement, when none was expected.
61+
postgresql.stream.eof:The backend has broken the connection. Possibly the action you have attempted has caused it to close.
62+
postgresql.stream.flush:An I/O error has occured while flushing the output - {1}
63+
postgresql.stream.ioerror:An I/O error occured while reading from backend - {1}
64+
postgresql.stream.toomuch:Too much data was received.
365
postgresql.unusual:Something unusual has occured to cause the driver to fail. Please report this exception: {1}
466
postgresql.unimplemented:This method is not yet implemented.
67+
postgresql.unexpected:An unexpected result was returned by a query.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp