From: Barry Lind Date: Sat, 13 Sep 2003 04:02:16 +0000 (+0000) Subject: More SQLState updates from Kim Ho at Redhat. X-Git-Tag: REL7_4_BETA3~28 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=509a9cd3f922c38c19d35e81bb1427d663ba4aba;p=postgresql More SQLState updates from Kim Ho at Redhat. Also a patch from Kris Jurka to correctly report SQLState support. Modified Files: jdbc/org/postgresql/Driver.java.in jdbc/org/postgresql/core/QueryExecutor.java jdbc/org/postgresql/fastpath/Fastpath.java jdbc/org/postgresql/geometric/PGbox.java jdbc/org/postgresql/geometric/PGcircle.java jdbc/org/postgresql/geometric/PGline.java jdbc/org/postgresql/geometric/PGlseg.java jdbc/org/postgresql/geometric/PGpath.java jdbc/org/postgresql/geometric/PGpoint.java jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSetMetaData.java jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java jdbc/org/postgresql/jdbc2/Array.java jdbc/org/postgresql/jdbc3/AbstractJdbc3DatabaseMetaData.java jdbc/org/postgresql/util/PGmoney.java jdbc/org/postgresql/util/PSQLState.java --- diff --git a/src/interfaces/jdbc/org/postgresql/Driver.java.in b/src/interfaces/jdbc/org/postgresql/Driver.java.in index 85fea4cadc..7c1436b812 100644 --- a/src/interfaces/jdbc/org/postgresql/Driver.java.in +++ b/src/interfaces/jdbc/org/postgresql/Driver.java.in @@ -6,7 +6,7 @@ * Copyright (c) 2003, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/Driver.java.in,v 1.35 2003/09/08 17:30:22 barry Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/Driver.java.in,v 1.36 2003/09/13 04:02:12 barry Exp $ * *------------------------------------------------------------------------- */ @@ -142,7 +142,7 @@ public class Driver implements java.sql.Driver { if (Driver.logDebug) Driver.debug("error", ex); - throw new PSQLException("postgresql.jvm.version", ex); + throw new PSQLException("postgresql.jvm.version", PSQLState.SYSTEM_ERROR, ex); } catch (PSQLException ex1) { @@ -155,7 +155,7 @@ public class Driver implements java.sql.Driver if (Driver.logDebug) { Driver.debug("error", ex2); } - throw new PSQLException("postgresql.unusual", ex2); + throw new PSQLException("postgresql.unusual", PSQLState.UNEXPECTED_ERROR, ex2); } } @@ -504,6 +504,6 @@ public class Driver implements java.sql.Driver //The build number should be incremented for every new build - private static int m_buildNumber = 208; + private static int m_buildNumber = 209; } diff --git a/src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java b/src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java index fcb1d0827e..ebc055e7eb 100644 --- a/src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java +++ b/src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java @@ -6,7 +6,7 @@ * Copyright (c) 2003, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/QueryExecutor.java,v 1.25 2003/09/09 10:49:16 barry Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/QueryExecutor.java,v 1.26 2003/09/13 04:02:13 barry Exp $ * *------------------------------------------------------------------------- */ @@ -311,7 +311,7 @@ public class QueryExecutor for ( int i = 0; i < m_binds.length ; i++ ) { if ( m_binds[i] == null ) - throw new PSQLException("postgresql.prep.param", PSQLState.PARAMETER_ERROR, new Integer(i + 1)); + throw new PSQLException("postgresql.prep.param", PSQLState.INVALID_PARAMETER_VALUE, new Integer(i + 1)); } try { @@ -352,7 +352,7 @@ public class QueryExecutor for ( int i = 0; i < m_binds.length ; i++ ) { if ( m_binds[i] == null ) - throw new PSQLException("postgresql.prep.param", PSQLState.PARAMETER_ERROR, new Integer(i + 1)); + throw new PSQLException("postgresql.prep.param", PSQLState.INVALID_PARAMETER_VALUE, new Integer(i + 1)); } try { diff --git a/src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java b/src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java index 08015d18db..6235651fed 100644 --- a/src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java +++ b/src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java @@ -6,7 +6,7 @@ * Copyright (c) 2003, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/fastpath/Attic/Fastpath.java,v 1.15 2003/09/08 17:30:22 barry Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/fastpath/Attic/Fastpath.java,v 1.16 2003/09/13 04:02:13 barry Exp $ * *------------------------------------------------------------------------- */ @@ -178,7 +178,7 @@ public class Fastpath break; default: - throw new PSQLException("postgresql.fp.protocol", new Character((char)c)); + throw new PSQLException("postgresql.fp.protocol", PSQLState.COMMUNICATION_ERROR, new Character((char)c)); } } @@ -279,12 +279,12 @@ public class Fastpath break; default: - throw new PSQLException("postgresql.fp.protocol", new Character((char)c)); + throw new PSQLException("postgresql.fp.protocol", PSQLState.COMMUNICATION_ERROR, new Character((char)c)); } } if ( errorMessage != null ) - throw new PSQLException("postgresql.fp.error", errorMessage.toString()); + throw new PSQLException("postgresql.fp.error", PSQLState.COMMUNICATION_ERROR, errorMessage.toString()); return result; } @@ -422,7 +422,7 @@ public class Fastpath // so, until we know we can do this (needs testing, on the TODO list) // for now, we throw the exception and do no lookups. if (id == null) - throw new PSQLException("postgresql.fp.unknown", name); + throw new PSQLException("postgresql.fp.unknown", PSQLState.UNEXPECTED_ERROR, name); return id.intValue(); } diff --git a/src/interfaces/jdbc/org/postgresql/geometric/PGbox.java b/src/interfaces/jdbc/org/postgresql/geometric/PGbox.java index 242a29413f..0f2d95305d 100644 --- a/src/interfaces/jdbc/org/postgresql/geometric/PGbox.java +++ b/src/interfaces/jdbc/org/postgresql/geometric/PGbox.java @@ -6,17 +6,19 @@ * Copyright (c) 2003, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGbox.java,v 1.4 2003/03/07 18:39:42 barry Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGbox.java,v 1.5 2003/09/13 04:02:14 barry Exp $ * *------------------------------------------------------------------------- */ package org.postgresql.geometric; -import java.sql.SQLException; -import java.io.Serializable; import org.postgresql.util.PGobject; import org.postgresql.util.PGtokenizer; import org.postgresql.util.PSQLException; +import org.postgresql.util.PSQLState; + +import java.io.Serializable; +import java.sql.SQLException; public class PGbox extends PGobject implements Serializable, Cloneable { @@ -78,7 +80,7 @@ public class PGbox extends PGobject implements Serializable, Cloneable { PGtokenizer t = new PGtokenizer(value, ','); if (t.getSize() != 2) - throw new PSQLException("postgresql.geo.box", value); + throw new PSQLException("postgresql.geo.box", PSQLState.DATA_TYPE_MISMATCH, value); point[0] = new PGpoint(t.getToken(0)); point[1] = new PGpoint(t.getToken(1)); diff --git a/src/interfaces/jdbc/org/postgresql/geometric/PGcircle.java b/src/interfaces/jdbc/org/postgresql/geometric/PGcircle.java index 43f008a510..1b0e562109 100644 --- a/src/interfaces/jdbc/org/postgresql/geometric/PGcircle.java +++ b/src/interfaces/jdbc/org/postgresql/geometric/PGcircle.java @@ -7,7 +7,7 @@ * Copyright (c) 2003, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGcircle.java,v 1.5 2003/05/29 04:39:48 barry Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGcircle.java,v 1.6 2003/09/13 04:02:14 barry Exp $ * *------------------------------------------------------------------------- */ @@ -16,6 +16,8 @@ package org.postgresql.geometric; import org.postgresql.util.PGobject; import org.postgresql.util.PGtokenizer; import org.postgresql.util.PSQLException; +import org.postgresql.util.PSQLState; + import java.io.Serializable; import java.sql.SQLException; @@ -78,7 +80,7 @@ public class PGcircle extends PGobject implements Serializable, Cloneable { PGtokenizer t = new PGtokenizer(PGtokenizer.removeAngle(s), ','); if (t.getSize() != 2) - throw new PSQLException("postgresql.geo.circle", s); + throw new PSQLException("postgresql.geo.circle", PSQLState.DATA_TYPE_MISMATCH, s); try { @@ -87,7 +89,7 @@ public class PGcircle extends PGobject implements Serializable, Cloneable } catch (NumberFormatException e) { - throw new PSQLException("postgresql.geo.circle", e); + throw new PSQLException("postgresql.geo.circle", PSQLState.DATA_TYPE_MISMATCH, e); } } diff --git a/src/interfaces/jdbc/org/postgresql/geometric/PGline.java b/src/interfaces/jdbc/org/postgresql/geometric/PGline.java index 5a108bd0b7..b5e686fc45 100644 --- a/src/interfaces/jdbc/org/postgresql/geometric/PGline.java +++ b/src/interfaces/jdbc/org/postgresql/geometric/PGline.java @@ -6,17 +6,19 @@ * Copyright (c) 2003, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGline.java,v 1.4 2003/03/07 18:39:42 barry Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGline.java,v 1.5 2003/09/13 04:02:15 barry Exp $ * *------------------------------------------------------------------------- */ package org.postgresql.geometric; -import java.io.Serializable; -import java.sql.SQLException; import org.postgresql.util.PGobject; import org.postgresql.util.PGtokenizer; import org.postgresql.util.PSQLException; +import org.postgresql.util.PSQLState; + +import java.io.Serializable; +import java.sql.SQLException; /* * Currently line is not yet implemented in the backend, but this class @@ -77,7 +79,7 @@ public class PGline extends PGobject implements Serializable, Cloneable { PGtokenizer t = new PGtokenizer(PGtokenizer.removeBox(s), ','); if (t.getSize() != 2) - throw new PSQLException("postgresql.geo.line", s); + throw new PSQLException("postgresql.geo.line", PSQLState.DATA_TYPE_MISMATCH, s); point[0] = new PGpoint(t.getToken(0)); point[1] = new PGpoint(t.getToken(1)); diff --git a/src/interfaces/jdbc/org/postgresql/geometric/PGlseg.java b/src/interfaces/jdbc/org/postgresql/geometric/PGlseg.java index c29aac4b98..5ffc645fc3 100644 --- a/src/interfaces/jdbc/org/postgresql/geometric/PGlseg.java +++ b/src/interfaces/jdbc/org/postgresql/geometric/PGlseg.java @@ -6,17 +6,19 @@ * Copyright (c) 2003, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGlseg.java,v 1.4 2003/03/07 18:39:42 barry Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGlseg.java,v 1.5 2003/09/13 04:02:15 barry Exp $ * *------------------------------------------------------------------------- */ package org.postgresql.geometric; -import java.io.Serializable; -import java.sql.SQLException; import org.postgresql.util.PGobject; import org.postgresql.util.PGtokenizer; import org.postgresql.util.PSQLException; +import org.postgresql.util.PSQLState; + +import java.io.Serializable; +import java.sql.SQLException; public class PGlseg extends PGobject implements Serializable, Cloneable { @@ -73,7 +75,7 @@ public class PGlseg extends PGobject implements Serializable, Cloneable { PGtokenizer t = new PGtokenizer(PGtokenizer.removeBox(s), ','); if (t.getSize() != 2) - throw new PSQLException("postgresql.geo.lseg"); + throw new PSQLException("postgresql.geo.lseg", PSQLState.DATA_TYPE_MISMATCH); point[0] = new PGpoint(t.getToken(0)); point[1] = new PGpoint(t.getToken(1)); diff --git a/src/interfaces/jdbc/org/postgresql/geometric/PGpath.java b/src/interfaces/jdbc/org/postgresql/geometric/PGpath.java index 0c40ce301b..13fc2d316f 100644 --- a/src/interfaces/jdbc/org/postgresql/geometric/PGpath.java +++ b/src/interfaces/jdbc/org/postgresql/geometric/PGpath.java @@ -6,17 +6,19 @@ * Copyright (c) 2003, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGpath.java,v 1.5 2003/03/07 18:39:42 barry Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGpath.java,v 1.6 2003/09/13 04:02:15 barry Exp $ * *------------------------------------------------------------------------- */ package org.postgresql.geometric; -import java.io.Serializable; -import java.sql.SQLException; import org.postgresql.util.PGobject; import org.postgresql.util.PGtokenizer; import org.postgresql.util.PSQLException; +import org.postgresql.util.PSQLState; + +import java.io.Serializable; +import java.sql.SQLException; public class PGpath extends PGobject implements Serializable, Cloneable { @@ -77,7 +79,7 @@ public class PGpath extends PGobject implements Serializable, Cloneable s = PGtokenizer.removePara(s); } else - throw new PSQLException("postgresql.geo.path"); + throw new PSQLException("postgresql.geo.path", PSQLState.DATA_TYPE_MISMATCH); PGtokenizer t = new PGtokenizer(s, ','); int npoints = t.getSize(); diff --git a/src/interfaces/jdbc/org/postgresql/geometric/PGpoint.java b/src/interfaces/jdbc/org/postgresql/geometric/PGpoint.java index c3c04b8ef6..30283df961 100644 --- a/src/interfaces/jdbc/org/postgresql/geometric/PGpoint.java +++ b/src/interfaces/jdbc/org/postgresql/geometric/PGpoint.java @@ -6,7 +6,7 @@ * Copyright (c) 2003, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGpoint.java,v 1.5 2003/05/29 04:39:48 barry Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGpoint.java,v 1.6 2003/09/13 04:02:15 barry Exp $ * *------------------------------------------------------------------------- */ @@ -15,6 +15,8 @@ package org.postgresql.geometric; import org.postgresql.util.PGobject; import org.postgresql.util.PGtokenizer; import org.postgresql.util.PSQLException; +import org.postgresql.util.PSQLState; + import java.awt.Point; import java.io.Serializable; import java.sql.SQLException; @@ -80,7 +82,7 @@ public class PGpoint extends PGobject implements Serializable, Cloneable } catch (NumberFormatException e) { - throw new PSQLException("postgresql.geo.point", e.toString()); + throw new PSQLException("postgresql.geo.point", PSQLState.DATA_TYPE_MISMATCH, e.toString()); } } diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java b/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java index 34a0f3596e..e3146a11c9 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java @@ -9,7 +9,7 @@ * Copyright (c) 2003, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.25 2003/09/09 10:49:16 barry Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.26 2003/09/13 04:02:15 barry Exp $ * *------------------------------------------------------------------------- */ @@ -373,7 +373,7 @@ public abstract class AbstractJdbc1Connection implements BaseConnection case AUTH_REQ_SCM: if (Driver.logDebug) Driver.debug("postgresql: SCM"); - throw new PSQLException("postgresql.con.scm"); + throw new PSQLException("postgresql.con.scm", PSQLState.CONNECTION_REJECTED); case AUTH_REQ_PASSWORD: diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java b/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java index bb68437335..1f37dd34c6 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java @@ -9,7 +9,7 @@ * Copyright (c) 2003, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.17 2003/09/09 10:49:16 barry Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.18 2003/09/13 04:02:15 barry Exp $ * *------------------------------------------------------------------------- */ @@ -211,7 +211,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet } catch (NumberFormatException e) { - throw new PSQLException("postgresql.res.badbyte", s); + throw new PSQLException("postgresql.res.badbyte", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return 0; // SQL NULL @@ -565,7 +565,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet Field field; if (columnIndex < 1 || columnIndex > fields.length) - throw new PSQLException("postgresql.res.colrange"); + throw new PSQLException("postgresql.res.colrange", PSQLState.INVALID_PARAMETER_VALUE); field = fields[columnIndex - 1]; // some fields can be null, mainly from those returned by MetaData methods @@ -788,7 +788,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet if ( this_row == null ) throw new PSQLException("postgresql.res.nextrequired"); if ( column < 1 || column > fields.length ) - throw new PSQLException("postgresql.res.colrange" ); + throw new PSQLException("postgresql.res.colrange", PSQLState.INVALID_PARAMETER_VALUE ); } //----------------- Formatting Methods ------------------- diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSetMetaData.java b/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSetMetaData.java index 681cc8b18f..fc0d5ee33a 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSetMetaData.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSetMetaData.java @@ -3,6 +3,7 @@ package org.postgresql.jdbc1; import org.postgresql.core.Field; import org.postgresql.util.PSQLException; +import org.postgresql.util.PSQLState; import java.sql.SQLException; import java.sql.Types; import java.util.Vector; @@ -454,7 +455,7 @@ public abstract class AbstractJdbc1ResultSetMetaData private Field getField(int columnIndex) throws SQLException { if (columnIndex < 1 || columnIndex > fields.length) - throw new PSQLException("postgresql.res.colrange"); + throw new PSQLException("postgresql.res.colrange", PSQLState.INVALID_PARAMETER_VALUE); return fields[columnIndex - 1]; } } diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java b/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java index 2f35880eff..979ae4d1ec 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java @@ -26,7 +26,7 @@ import java.sql.Timestamp; import java.sql.Types; import java.util.Vector; -/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.35 2003/09/09 10:49:16 barry Exp $ +/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.36 2003/09/13 04:02:15 barry Exp $ * This class defines methods of the jdbc1 specification. This class is * extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2 * methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement @@ -292,7 +292,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement public boolean execute() throws SQLException { if (isFunction && !returnTypeSet) - throw new PSQLException("postgresql.call.noreturntype"); + throw new PSQLException("postgresql.call.noreturntype", PSQLState.STATEMENT_NOT_ALLOWED_IN_FUNCTION_CALL); if (isFunction) { // set entry 1 to dummy entry.. m_binds[0] = ""; // dummy entry which ensured that no one overrode @@ -1641,9 +1641,9 @@ public abstract class AbstractJdbc1Statement implements BaseStatement public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException { if (parameterIndex != 1) - throw new PSQLException ("postgresql.call.noinout"); + throw new PSQLException ("postgresql.call.noinout", PSQLState.STATEMENT_NOT_ALLOWED_IN_FUNCTION_CALL); if (!isFunction) - throw new PSQLException ("postgresql.call.procasfunc", originalSql); + throw new PSQLException ("postgresql.call.procasfunc", PSQLState.STATEMENT_NOT_ALLOWED_IN_FUNCTION_CALL,originalSql); // functionReturnType contains the user supplied value to check // testReturn contains a modified version to make it easier to @@ -1955,7 +1955,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement private void bind(int paramIndex, Object s, String type) throws SQLException { if (paramIndex < 1 || paramIndex > m_binds.length) - throw new PSQLException("postgresql.prep.range", PSQLState.PARAMETER_ERROR); + throw new PSQLException("postgresql.prep.range", PSQLState.INVALID_PARAMETER_VALUE); if (paramIndex == 1 && isFunction) // need to registerOut instead throw new PSQLException ("postgresql.call.funcover"); m_binds[paramIndex - 1] = s; @@ -1997,7 +1997,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement isValid = false; index = l_sql.indexOf ("call"); if (index == -1 || !isValid) - throw new PSQLException ("postgresql.call.malformed", + throw new PSQLException ("postgresql.call.malformed",PSQLState.STATEMENT_NOT_ALLOWED_IN_FUNCTION_CALL, new Object[]{l_sql, JDBC_SYNTAX}); l_sql = l_sql.replace ('{', ' '); // replace these characters l_sql = l_sql.replace ('}', ' '); @@ -2027,7 +2027,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement { checkIndex (parameterIndex); if (type1 != this.testReturn && type2 != this.testReturn) - throw new PSQLException("postgresql.call.wrongget", + throw new PSQLException("postgresql.call.wrongget", PSQLState.MOST_SPECIFIC_TYPE_DOES_NOT_MATCH, new Object[]{"java.sql.Types=" + testReturn, getName, "java.sql.Types=" + type1}); @@ -2040,7 +2040,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement { checkIndex (parameterIndex); if (type != this.testReturn) - throw new PSQLException("postgresql.call.wrongget", + throw new PSQLException("postgresql.call.wrongget", PSQLState.MOST_SPECIFIC_TYPE_DOES_NOT_MATCH, new Object[]{"java.sql.Types=" + testReturn, getName, "java.sql.Types=" + type}); @@ -2053,9 +2053,9 @@ public abstract class AbstractJdbc1Statement implements BaseStatement private void checkIndex (int parameterIndex) throws SQLException { if (!isFunction) - throw new PSQLException("postgresql.call.noreturntype"); + throw new PSQLException("postgresql.call.noreturntype", PSQLState.STATEMENT_NOT_ALLOWED_IN_FUNCTION_CALL); if (parameterIndex != 1) - throw new PSQLException("postgresql.call.noinout"); + throw new PSQLException("postgresql.call.noinout", PSQLState.STATEMENT_NOT_ALLOWED_IN_FUNCTION_CALL); } diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java b/src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java index 3921516928..e7f723365f 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java @@ -9,7 +9,7 @@ * Copyright (c) 2003, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.22 2003/09/08 17:30:22 barry Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.23 2003/09/13 04:02:15 barry Exp $ * *------------------------------------------------------------------------- */ @@ -261,7 +261,7 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra return null; if (i < 1 || i > fields.length) - throw new PSQLException("postgresql.res.colrange"); + throw new PSQLException("postgresql.res.colrange", PSQLState.INVALID_PARAMETER_VALUE); return (java.sql.Array) new org.postgresql.jdbc2.Array( connection, i, fields[i - 1], this ); } diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java b/src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java index 8f83c74273..d65634a60d 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java @@ -3,6 +3,7 @@ package org.postgresql.jdbc2; import org.postgresql.core.Field; import org.postgresql.util.PSQLException; +import org.postgresql.util.PSQLState; import java.sql.SQLException; import java.sql.Types; import java.util.Vector; @@ -450,7 +451,7 @@ public abstract class AbstractJdbc2ResultSetMetaData extends org.postgresql.jdbc private Field getField(int columnIndex) throws SQLException { if (columnIndex < 1 || columnIndex > fields.length) - throw new PSQLException("postgresql.res.colrange"); + throw new PSQLException("postgresql.res.colrange", PSQLState.INVALID_PARAMETER_VALUE); return fields[columnIndex - 1]; } diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/Array.java b/src/interfaces/jdbc/org/postgresql/jdbc2/Array.java index 418a094263..e38b0c92ed 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc2/Array.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc2/Array.java @@ -5,6 +5,8 @@ import org.postgresql.core.BaseResultSet; import org.postgresql.core.BaseStatement; import org.postgresql.core.Field; import org.postgresql.util.PSQLException; +import org.postgresql.util.PSQLState; + import java.math.BigDecimal; import java.sql.ResultSet; import java.sql.SQLException; @@ -77,7 +79,7 @@ public class Array implements java.sql.Array throw org.postgresql.Driver.notImplemented(); if (index < 1) - throw new PSQLException("postgresql.arr.range"); + throw new PSQLException("postgresql.arr.range", PSQLState.DATA_ERROR); Object retVal = null; ArrayList array = new ArrayList(); @@ -127,7 +129,7 @@ public class Array implements java.sql.Array count = arrayContents.length; index--; if ( index + count > arrayContents.length ) - throw new PSQLException("postgresql.arr.range"); + throw new PSQLException("postgresql.arr.range", PSQLState.DATA_ERROR); int i = 0; switch ( getBaseType() ) diff --git a/src/interfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3DatabaseMetaData.java b/src/interfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3DatabaseMetaData.java index 781544e16e..7ebdf38271 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3DatabaseMetaData.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3DatabaseMetaData.java @@ -323,7 +323,7 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2 */ public int getSQLStateType() throws SQLException { - throw org.postgresql.Driver.notImplemented(); + return DatabaseMetaData.sqlStateSQL99; } /** diff --git a/src/interfaces/jdbc/org/postgresql/util/PGmoney.java b/src/interfaces/jdbc/org/postgresql/util/PGmoney.java index 970c8367b7..175d166e2d 100644 --- a/src/interfaces/jdbc/org/postgresql/util/PGmoney.java +++ b/src/interfaces/jdbc/org/postgresql/util/PGmoney.java @@ -6,7 +6,7 @@ * Copyright (c) 2003, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/util/Attic/PGmoney.java,v 1.5 2003/03/07 18:39:46 barry Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/util/Attic/PGmoney.java,v 1.6 2003/09/13 04:02:16 barry Exp $ * *------------------------------------------------------------------------- */ @@ -72,7 +72,7 @@ public class PGmoney extends PGobject implements Serializable, Cloneable } catch (NumberFormatException e) { - throw new PSQLException("postgresql.money", e); + throw new PSQLException("postgresql.money", PSQLState.NUMERIC_CONSTANT_OUT_OF_RANGE, e); } } diff --git a/src/interfaces/jdbc/org/postgresql/util/PSQLState.java b/src/interfaces/jdbc/org/postgresql/util/PSQLState.java index 96d14167a5..152170e0c9 100644 --- a/src/interfaces/jdbc/org/postgresql/util/PSQLState.java +++ b/src/interfaces/jdbc/org/postgresql/util/PSQLState.java @@ -27,21 +27,25 @@ // begin constant state codes public final static PSQLState UNKNOWN_STATE = new PSQLState(""); + public final static PSQLState NO_DATA = new PSQLState("02000"); + public final static PSQLState INVALID_PARAMETER_TYPE = new PSQLState("07006"); + public final static PSQLState CONNECTION_UNABLE_TO_CONNECT = new PSQLState("08001"); + public final static PSQLState CONNECTION_DOES_NOT_EXIST = new PSQLState("08003"); + public final static PSQLState CONNECTION_REJECTED = new PSQLState("08004"); + public final static PSQLState CONNECTION_FAILURE = new PSQLState("08006"); + public final static PSQLState CONNECTION_FAILURE_DURING_TRANSACTION = new PSQLState("08007"); public final static PSQLState COMMUNICATION_ERROR = new PSQLState("08S01"); - public final static PSQLState NO_DATA = new PSQLState("02000"); - public final static PSQLState CONNECTION_FAILURE_DURING_TRANSACTION = new PSQLState("08007"); - public final static PSQLState UNEXPECTED_ERROR = new PSQLState("99999"); - public final static PSQLState NUMERIC_VALUE_OUT_OF_RANGE = new PSQLState("22003"); - public final static PSQLState BAD_DATETIME_FORMAT = new PSQLState("22007"); - public final static PSQLState DATA_ERROR = new PSQLState("22000"); - public final static PSQLState CONNECTION_DOES_NOT_EXIST = new PSQLState("08003"); - public final static PSQLState CONNECTION_REJECTED = new PSQLState("08004"); - public final static PSQLState CONNECTION_UNABLE_TO_CONNECT = new PSQLState("08001"); - public final static PSQLState CONNECTION_FAILURE = new PSQLState("08006"); - public final static PSQLState CONNECTION_CLOSED = new PSQLState("08003"); - public final static PSQLState NOT_IMPLEMENTED = new PSQLState("0A000"); - public final static PSQLState INVALID_PARAMETER_TYPE = new PSQLState("07006"); - public final static PSQLState PARAMETER_ERROR = new PSQLState("07001"); + public final static PSQLState NOT_IMPLEMENTED = new PSQLState("0A000"); + public final static PSQLState DATA_ERROR = new PSQLState("22000"); + public final static PSQLState NUMERIC_VALUE_OUT_OF_RANGE = new PSQLState("22003"); + public final static PSQLState BAD_DATETIME_FORMAT = new PSQLState("22007"); + public final static PSQLState MOST_SPECIFIC_TYPE_DOES_NOT_MATCH = new PSQLState("2200G"); + public final static PSQLState INVALID_PARAMETER_VALUE = new PSQLState("22023"); public final static PSQLState TRANSACTION_STATE_INVALID = new PSQLState("25000"); + public final static PSQLState STATEMENT_NOT_ALLOWED_IN_FUNCTION_CALL = new PSQLState("2F003"); + public final static PSQLState NUMERIC_CONSTANT_OUT_OF_RANGE = new PSQLState("42820'"); + public final static PSQLState DATA_TYPE_MISMATCH = new PSQLState("42821"); + public final static PSQLState SYSTEM_ERROR = new PSQLState("60000"); + public final static PSQLState UNEXPECTED_ERROR = new PSQLState("99999"); }