From dc88d74af3c8ae7dbf3721b7df268e77d77e0448 Mon Sep 17 00:00:00 2001 From: Peter Mount Date: Wed, 23 Jun 1999 05:56:20 +0000 Subject: [PATCH] Some fixes supplied by Jon Nielsen jonfn@image.dk --- src/interfaces/jdbc/CHANGELOG | 23 +- src/interfaces/jdbc/Makefile | 3 +- .../jdbc/postgresql/CallableStatement.java | 303 --------------------- src/interfaces/jdbc/postgresql/Driver.java | 6 +- src/interfaces/jdbc/postgresql/errors.properties | 80 +++--- .../jdbc/postgresql/errors_fr.properties | 7 +- 6 files changed, 65 insertions(+), 357 deletions(-) delete mode 100644 src/interfaces/jdbc/postgresql/CallableStatement.java diff --git a/src/interfaces/jdbc/CHANGELOG b/src/interfaces/jdbc/CHANGELOG index 35c203c5a4..3fc584b00e 100644 --- a/src/interfaces/jdbc/CHANGELOG +++ b/src/interfaces/jdbc/CHANGELOG @@ -1,6 +1,14 @@ -Web May 19 00:20:00 BST 1999 - - Internationalisation now done. Surprising that there's 68 error messages - in the driver ;-) +Wed Jun 23 06:50:00 BST 1999 + - Fixed error in errors.properties where the arguments are 0 based not + 1 based + - Fixed bug in postgresql.Driver where exception is thrown, then + intercepted rather than being passed to the calling application. + - Removed the file postgresql/CallableStatement, as it's not used and + really exists in the jdbc1 & jdbc2 sub packages only. + +Wed May 19 00:20:00 BST 1999 + - Internationalisation now done. Surprising that there's 68 error + messages in the driver ;-) Tue May 18 07:00:00 BST 1999 - Set the ImageViewer application to use transactions @@ -12,14 +20,15 @@ Tue May 18 00:00:00 BST 1999 Mon May 17 23:40:00 BST 1999 - PG_Stream.close() now attempts to send the close connection message to the backend before closing the streams - - Added batch support in the JDBC2, supplied by Yutaka Tanida + - Added batch support in the JDBC2, supplied by Yutaka Tanida + - Removed the old datestyle code. Now the driver uses only ISO. - Removed some files in the postgresql directory still in CVS that were moved since 6.4.x (DatabaseMetaData.java PreparedStatement.java ResultSetMetaData.java Statement.java) - - Internationalisation of the error messages is partially implemented, however - it's not enabled as it only works when the jar file is _not_ used, and - work needs to be done. + - Internationalisation of the error messages is partially implemented, + however it's not enabled as it only works when the jar file is + _not_ used, and work needs to be done. Sun Apr 11 17:00:00 BST 1999 - getUpdateCount() now returns the actual update count (before it diff --git a/src/interfaces/jdbc/Makefile b/src/interfaces/jdbc/Makefile index f60f3dcb94..d942767b0c 100644 --- a/src/interfaces/jdbc/Makefile +++ b/src/interfaces/jdbc/Makefile @@ -4,7 +4,7 @@ # Makefile for Java JDBC interface # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/Makefile,v 1.13 1999/05/17 22:58:18 peter Exp $ +# $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/Makefile,v 1.14 1999/06/23 05:56:17 peter Exp $ # #------------------------------------------------------------------------- @@ -161,7 +161,6 @@ clean: # Java is unlike C in that one source file can generate several # _Different_ file names # -postgresql/CallableStatement.class: postgresql/CallableStatement.java postgresql/Connection.class: postgresql/Connection.java postgresql/DatabaseMetaData.class: postgresql/DatabaseMetaData.java postgresql/Driver.class: postgresql/Driver.java diff --git a/src/interfaces/jdbc/postgresql/CallableStatement.java b/src/interfaces/jdbc/postgresql/CallableStatement.java deleted file mode 100644 index 7f56a42b2a..0000000000 --- a/src/interfaces/jdbc/postgresql/CallableStatement.java +++ /dev/null @@ -1,303 +0,0 @@ -package postgresql; - -import java.sql.*; -import java.math.*; - -/** - * CallableStatement is used to execute SQL stored procedures. - * - *

JDBC provides a stored procedure SQL escape that allows stored - * procedures to be called in a standard way for all RDBMS's. This escape - * syntax has one form that includes a result parameter and one that does - * not. If used, the result parameter must be registered as an OUT - * parameter. The other parameters may be used for input, output or both. - * Parameters are refered to sequentially, by number. The first parameter - * is 1. - * - * {?= call [,, ...]} - * {call [,, ...]} - * - * - *

IN parameter values are set using the set methods inherited from - * PreparedStatement. The type of all OUT parameters must be registered - * prior to executing the stored procedure; their values are retrieved - * after execution via the get methods provided here. - * - *

A Callable statement may return a ResultSet or multiple ResultSets. - * Multiple ResultSets are handled using operations inherited from - * Statement. - * - *

For maximum portability, a call's ResultSets and update counts should - * be processed prior to getting the values of output parameters. - * - * @see Connection#prepareCall - * @see ResultSet - */ - -public class CallableStatement extends PreparedStatement implements java.sql.CallableStatement -{ - /** - * @exception SQLException on failure - */ - CallableStatement(Connection c,String q) throws SQLException - { - super(c,q); - } - - /** - * Before executing a stored procedure call you must explicitly - * call registerOutParameter to register the java.sql.Type of each - * out parameter. - * - *

Note: When reading the value of an out parameter, you must use - * the getXXX method whose Java type XXX corresponds to the - * parameter's registered SQL type. - * - * @param parameterIndex the first parameter is 1, the second is 2,... - * @param sqlType SQL type code defined by java.sql.Types; for - * parameters of type Numeric or Decimal use the version of - * registerOutParameter that accepts a scale value - * @exception SQLException if a database-access error occurs. - */ - public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException { - } - - /** - * You must also specify the scale for numeric/decimal types: - * - *

Note: When reading the value of an out parameter, you must use - * the getXXX method whose Java type XXX corresponds to the - * parameter's registered SQL type. - * - * @param parameterIndex the first parameter is 1, the second is 2,... - * @param sqlType use either java.sql.Type.NUMERIC or java.sql.Type.DECIMAL - * @param scale a value greater than or equal to zero representing the - * desired number of digits to the right of the decimal point - * @exception SQLException if a database-access error occurs. - */ - public void registerOutParameter(int parameterIndex, int sqlType, - int scale) throws SQLException - { - } - - // Old api? - //public boolean isNull(int parameterIndex) throws SQLException { - //return true; - //} - - /** - * An OUT parameter may have the value of SQL NULL; wasNull - * reports whether the last value read has this special value. - * - *

Note: You must first call getXXX on a parameter to read its - * value and then call wasNull() to see if the value was SQL NULL. - * @return true if the last parameter read was SQL NULL - * @exception SQLException if a database-access error occurs. - */ - public boolean wasNull() throws SQLException { - // check to see if the last access threw an exception - return false; // fake it for now - } - - // Old api? - //public String getChar(int parameterIndex) throws SQLException { - //return null; - //} - - /** - * Get the value of a CHAR, VARCHAR, or LONGVARCHAR parameter as a - * Java String. - * - * @param parameterIndex the first parameter is 1, the second is 2,... - * @return the parameter value; if the value is SQL NULL, the result is null - * @exception SQLException if a database-access error occurs. - */ - public String getString(int parameterIndex) throws SQLException { - return null; - } - //public String getVarChar(int parameterIndex) throws SQLException { - // return null; - //} - - //public String getLongVarChar(int parameterIndex) throws SQLException { - //return null; - //} - - /** - * Get the value of a BIT parameter as a Java boolean. - * - * @param parameterIndex the first parameter is 1, the second is 2,... - * @return the parameter value; if the value is SQL NULL, the result is false - * @exception SQLException if a database-access error occurs. - */ - public boolean getBoolean(int parameterIndex) throws SQLException { - return false; - } - - /** - * Get the value of a TINYINT parameter as a Java byte. - * - * @param parameterIndex the first parameter is 1, the second is 2,... - * @return the parameter value; if the value is SQL NULL, the result is 0 - * @exception SQLException if a database-access error occurs. - */ - public byte getByte(int parameterIndex) throws SQLException { - return 0; - } - - /** - * Get the value of a SMALLINT parameter as a Java short. - * - * @param parameterIndex the first parameter is 1, the second is 2,... - * @return the parameter value; if the value is SQL NULL, the result is 0 - * @exception SQLException if a database-access error occurs. - */ - public short getShort(int parameterIndex) throws SQLException { - return 0; - } - - /** - * Get the value of an INTEGER parameter as a Java int. - * - * @param parameterIndex the first parameter is 1, the second is 2,... - * @return the parameter value; if the value is SQL NULL, the result is 0 - * @exception SQLException if a database-access error occurs. - */ -public int getInt(int parameterIndex) throws SQLException { - return 0; - } - - /** - * Get the value of a BIGINT parameter as a Java long. - * - * @param parameterIndex the first parameter is 1, the second is 2,... - * @return the parameter value; if the value is SQL NULL, the result is 0 - * @exception SQLException if a database-access error occurs. - */ - public long getLong(int parameterIndex) throws SQLException { - return 0; - } - - /** - * Get the value of a FLOAT parameter as a Java float. - * - * @param parameterIndex the first parameter is 1, the second is 2,... - * @return the parameter value; if the value is SQL NULL, the result is 0 - * @exception SQLException if a database-access error occurs. - */ - public float getFloat(int parameterIndex) throws SQLException { - return (float) 0.0; - } - - /** - * Get the value of a DOUBLE parameter as a Java double. - * - * @param parameterIndex the first parameter is 1, the second is 2,... - * @return the parameter value; if the value is SQL NULL, the result is 0 - * @exception SQLException if a database-access error occurs. - */ - public double getDouble(int parameterIndex) throws SQLException { - return 0.0; - } - - /** - * Get the value of a NUMERIC parameter as a java.math.BigDecimal - * object. - * - * @param parameterIndex the first parameter is 1, the second is 2,... - * @param scale a value greater than or equal to zero representing the - * desired number of digits to the right of the decimal point - * @return the parameter value; if the value is SQL NULL, the result is null - * @exception SQLException if a database-access error occurs. - */ - public BigDecimal getBigDecimal(int parameterIndex, int scale) - throws SQLException { - return null; - } - - /** - * Get the value of a SQL BINARY or VARBINARY parameter as a Java - * byte[] - * - * @param parameterIndex the first parameter is 1, the second is 2,... - * @return the parameter value; if the value is SQL NULL, the result is null - * @exception SQLException if a database-access error occurs. - */ - public byte[] getBytes(int parameterIndex) throws SQLException { - return null; - } - - // New API (JPM) (getLongVarBinary) - //public byte[] getBinaryStream(int parameterIndex) throws SQLException { - //return null; - //} - - /** - * Get the value of a SQL DATE parameter as a java.sql.Date object - * - * @param parameterIndex the first parameter is 1, the second is 2,... - * @return the parameter value; if the value is SQL NULL, the result is null - * @exception SQLException if a database-access error occurs. - */ - public java.sql.Date getDate(int parameterIndex) throws SQLException { - return null; - } - - /** - * Get the value of a SQL TIME parameter as a java.sql.Time object. - * - * @param parameterIndex the first parameter is 1, the second is 2,... - * @return the parameter value; if the value is SQL NULL, the result is null - * @exception SQLException if a database-access error occurs. - */ - public java.sql.Time getTime(int parameterIndex) throws SQLException { - return null; - } - - /** - * Get the value of a SQL TIMESTAMP parameter as a java.sql.Timestamp object. - * - * @param parameterIndex the first parameter is 1, the second is 2,... - * @return the parameter value; if the value is SQL NULL, the result is null - * @exception SQLException if a database-access error occurs. - */ - public java.sql.Timestamp getTimestamp(int parameterIndex) - throws SQLException { - return null; - } - - //---------------------------------------------------------------------- - // Advanced features: - - // You can obtain a ParameterMetaData object to get information - // about the parameters to this CallableStatement. - //public DatabaseMetaData getMetaData() { - //return null; - //} - - // getObject returns a Java object for the parameter. - // See the JDBC spec's "Dynamic Programming" chapter for details. - /** - * Get the value of a parameter as a Java object. - * - *

This method returns a Java object whose type coresponds to the - * SQL type that was registered for this parameter using - * registerOutParameter. - * - *

Note that this method may be used to read datatabase-specific, - * abstract data types. This is done by specifying a targetSqlType - * of java.sql.types.OTHER, which allows the driver to return a - * database-specific Java type. - * - *

See the JDBC spec's "Dynamic Programming" chapter for details. - * - * @param parameterIndex the first parameter is 1, the second is 2,... - * @return A java.lang.Object holding the OUT parameter value. - * @exception SQLException if a database-access error occurs. - */ - public Object getObject(int parameterIndex) - throws SQLException { - return null; - } -} - diff --git a/src/interfaces/jdbc/postgresql/Driver.java b/src/interfaces/jdbc/postgresql/Driver.java index 21d1300a74..2c78b614ba 100644 --- a/src/interfaces/jdbc/postgresql/Driver.java +++ b/src/interfaces/jdbc/postgresql/Driver.java @@ -104,11 +104,13 @@ public class Driver implements java.sql.Driver return (java.sql.Connection)con; } catch(ClassNotFoundException ex) { throw new PSQLException("postgresql.jvm.version",ex); + } catch(PSQLException(ex1) { + // re-throw the exception, otherwise it will be caught next, and a + // postgresql.unusual error will be returned instead. + throw ex1; } catch(Exception ex2) { throw new PSQLException("postgresql.unusual",ex2); } - // The old call - remove before posting - //return new Connection (host(), port(), props, database(), url, this); } /** diff --git a/src/interfaces/jdbc/postgresql/errors.properties b/src/interfaces/jdbc/postgresql/errors.properties index 7d8e5d4871..53b43c4227 100644 --- a/src/interfaces/jdbc/postgresql/errors.properties +++ b/src/interfaces/jdbc/postgresql/errors.properties @@ -1,67 +1,67 @@ # This is the default errors -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. +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.call:Callable Statements are not supported at this time. -postgresql.con.creobj:Failed to create object for {1} {2} -postgresql.con.failed:The connection attempt failed because {1} -postgresql.con.fathom:Unable to fathom update count {1} +postgresql.con.creobj:Failed to create object for {0} {1} +postgresql.con.failed:The connection attempt failed because {0} +postgresql.con.fathom:Unable to fathom update count {0} postgresql.con.garbled:Garbled data received. -postgresql.con.ioerror:An IO erro occured while sending to the backend - {1} +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.kerb5:Kerberos 5 authentication is not supported by this driver. postgresql.con.multres:Cannot handle multiple result groups. 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.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 - {1} -postgresql.con.toolong:The SQL Statement is too long - {1} +postgresql.con.strobjex:Failed to store object - {0} +postgresql.con.toolong:The SQL Statement is too long - {0} postgresql.con.tuple:Tuple received before MetaData. -postgresql.con.type:Unknown Response Type {1} +postgresql.con.type:Unknown Response Type {0} postgresql.con.user:The user property is missing. It is mandatory. -postgresql.fp.error:FastPath call returned {1} -postgresql.fp.expint:Fastpath call {1} - No result was returned and we expected an integer. -postgresql.fp.protocol:FastPath protocol error: {1} -postgresql.fp.send:Failed to send fastpath call {1} {2} -postgresql.fp.unknown:The fastpath function {1} is unknown. -postgresql.geo.box:Conversion of box failed - {1} -postgresql.geo.circle:Conversion of circle failed - {1} -postgresql.geo.line:Conversion of line failed - {1} -postgresql.geo.lseg:Conversion of lseg failed - {1} +postgresql.fp.error:FastPath call returned {0} +postgresql.fp.expint:Fastpath call {0} - No result was returned and we expected an integer. +postgresql.fp.protocol:FastPath protocol error: {0} +postgresql.fp.send:Failed to send fastpath call {0} {1} +postgresql.fp.unknown:The fastpath function {0} is unknown. +postgresql.geo.box:Conversion of box failed - {0} +postgresql.geo.circle:Conversion of circle failed - {0} +postgresql.geo.line:Conversion of line failed - {0} +postgresql.geo.lseg:Conversion of lseg failed - {0} postgresql.geo.path:Cannot tell if path is open or closed. -postgresql.geo.point:Conversion of point failed - {1} -postgresql.jvm.version:The postgresql.jar file does not contain the correct JDBC classes for this JVM. Try rebuilding.\nException thrown was {1} +postgresql.geo.point:Conversion of point failed - {0} +postgresql.jvm.version:The postgresql.jar file does not contain the correct JDBC classes for this JVM. Try rebuilding. If that fails, try forcing the version supplying it to the command line using the argument -Djava.version=1.1 or -Djava.version=1.2\nException thrown was {0} postgresql.lo.init:failed to initialise LargeObject API -postgresql.money:conversion of money failed - {1}. +postgresql.money:conversion of money failed - {0}. postgresql.prep.is:InputStream as parameter not supported -postgresql.prep.param:No value specified for parameter {1}. +postgresql.prep.param:No value specified for parameter {0}. postgresql.prep.range:Parameter index out of range. postgresql.prep.type:Unknown Types value. -postgresql.res.badbigdec:Bad BigDecimal {1} -postgresql.res.badbyte:Bad Byte {1} -postgresql.res.baddate:Bad Date Format at {1} in {2} -postgresql.res.baddouble:Bad Double {1} -postgresql.res.badfloat:Bad Float {1} -postgresql.res.badint:Bad Integer {1} -postgresql.res.badlong:Bad Long {1} -postgresql.res.badshort:Bad Short {1} -postgresql.res.badtime:Bad Time {1} -postgresql.res.badtimestamp:Bad Timestamp Format at {1} in {2} -postgresql.res.colname:The column name {1} not found. +postgresql.res.badbigdec:Bad BigDecimal {0} +postgresql.res.badbyte:Bad Byte {0} +postgresql.res.baddate:Bad Date Format at {0} in {1} +postgresql.res.baddouble:Bad Double {0} +postgresql.res.badfloat:Bad Float {0} +postgresql.res.badint:Bad Integer {0} +postgresql.res.badlong:Bad Long {0} +postgresql.res.badshort:Bad Short {0} +postgresql.res.badtime:Bad Time {0} +postgresql.res.badtimestamp:Bad Timestamp Format at {0} in {1} +postgresql.res.colname:The column name {0} not found. postgresql.res.colrange:The column index is out of range. postgresql.serial.interface:You cannot serialize an interface. -postgresql.serial.namelength:Class & Package name length cannot be longer than 32 characters. {1} is {2} characters. -postgresql.serial.noclass:No class found for {1}. -postgresql.serial.table:The table for {1} is not in the database. Contact the DBA, as the database is in an inconsistent state. -postgresql.serial.underscore:Class names may not have _ in them. You supplied {1}. +postgresql.serial.namelength:Class & Package name length cannot be longer than 32 characters. {0} is {1} characters. +postgresql.serial.noclass:No class found for {0}. +postgresql.serial.table:The table for {0} is not in the database. Contact the DBA, as the database is in an inconsistent state. +postgresql.serial.underscore:Class names may not have _ in them. You supplied {0}. postgresql.stat.batch.empty:The batch is empty. There is nothing to execute. -postgresql.stat.batch.error:Batch entry {1} {2} was aborted. +postgresql.stat.batch.error:Batch entry {0} {1} was aborted. postgresql.stat.maxfieldsize:An attempt to setMaxFieldSize() failed - compile time default in force. postgresql.stat.noresult:No results were returned by the query. postgresql.stat.result:A result was returned by the statement, when none was expected. postgresql.stream.eof:The backend has broken the connection. Possibly the action you have attempted has caused it to close. -postgresql.stream.flush:An I/O error has occured while flushing the output - {1} -postgresql.stream.ioerror:An I/O error occured while reading from backend - {1} +postgresql.stream.flush:An I/O error has occured while flushing the output - {0} +postgresql.stream.ioerror:An I/O error occured while reading from backend - {0} postgresql.stream.toomuch:Too much data was received. -postgresql.unusual:Something unusual has occured to cause the driver to fail. Please report this exception: {1} +postgresql.unusual:Something unusual has occured to cause the driver to fail. Please report this exception: {0} postgresql.unimplemented:This method is not yet implemented. postgresql.unexpected:An unexpected result was returned by a query. diff --git a/src/interfaces/jdbc/postgresql/errors_fr.properties b/src/interfaces/jdbc/postgresql/errors_fr.properties index 8db1d3df21..c65b28187e 100644 --- a/src/interfaces/jdbc/postgresql/errors_fr.properties +++ b/src/interfaces/jdbc/postgresql/errors_fr.properties @@ -1,4 +1,5 @@ -# This is the default errors -postgresql.jvm.version:Le fichier de postgresql.jar ne contient pas les classes correctes de JDBC pour ce JVM. Try que rebuilding.\nException jetées était {1} -postgresql.unusual:Quelque chose de peu commun s'est produit pour faire échouer le gestionnaire. Veuillez enregistrer cette exception: {1} +# This is the french version of some errors. Errors not in this file +# are handled by the parent errors.properties file. +postgresql.jvm.version:Le fichier de postgresql.jar ne contient pas les classes correctes de JDBC pour ce JVM. Try que rebuilding.\nException jetées était {0} +postgresql.unusual:Quelque chose de peu commun s'est produit pour faire échouer le gestionnaire. Veuillez enregistrer cette exception: {0} postgresql.unimplemented:Cette méthode n'est pas encore appliquée. -- 2.11.0