Commit 509a9cd3 authored by Barry Lind's avatar Barry Lind

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
parent f8c365c8
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * 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 ...@@ -142,7 +142,7 @@ public class Driver implements java.sql.Driver
{ {
if (Driver.logDebug) if (Driver.logDebug)
Driver.debug("error", ex); Driver.debug("error", ex);
throw new PSQLException("postgresql.jvm.version", ex); throw new PSQLException("postgresql.jvm.version", PSQLState.SYSTEM_ERROR, ex);
} }
catch (PSQLException ex1) catch (PSQLException ex1)
{ {
...@@ -155,7 +155,7 @@ public class Driver implements java.sql.Driver ...@@ -155,7 +155,7 @@ public class Driver implements java.sql.Driver
if (Driver.logDebug) { if (Driver.logDebug) {
Driver.debug("error", ex2); 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 ...@@ -504,6 +504,6 @@ public class Driver implements java.sql.Driver
//The build number should be incremented for every new build //The build number should be incremented for every new build
private static int m_buildNumber = 208; private static int m_buildNumber = 209;
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * 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 ...@@ -311,7 +311,7 @@ public class QueryExecutor
for ( int i = 0; i < m_binds.length ; i++ ) for ( int i = 0; i < m_binds.length ; i++ )
{ {
if ( m_binds[i] == null ) 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 try
{ {
...@@ -352,7 +352,7 @@ public class QueryExecutor ...@@ -352,7 +352,7 @@ public class QueryExecutor
for ( int i = 0; i < m_binds.length ; i++ ) for ( int i = 0; i < m_binds.length ; i++ )
{ {
if ( m_binds[i] == null ) 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 try
{ {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * 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 ...@@ -178,7 +178,7 @@ public class Fastpath
break; break;
default: 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 ...@@ -279,12 +279,12 @@ public class Fastpath
break; break;
default: 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 ) if ( errorMessage != null )
throw new PSQLException("postgresql.fp.error", errorMessage.toString()); throw new PSQLException("postgresql.fp.error", PSQLState.COMMUNICATION_ERROR, errorMessage.toString());
return result; return result;
} }
...@@ -422,7 +422,7 @@ public class Fastpath ...@@ -422,7 +422,7 @@ public class Fastpath
// so, until we know we can do this (needs testing, on the TODO list) // so, until we know we can do this (needs testing, on the TODO list)
// for now, we throw the exception and do no lookups. // for now, we throw the exception and do no lookups.
if (id == null) if (id == null)
throw new PSQLException("postgresql.fp.unknown", name); throw new PSQLException("postgresql.fp.unknown", PSQLState.UNEXPECTED_ERROR, name);
return id.intValue(); return id.intValue();
} }
......
...@@ -6,17 +6,19 @@ ...@@ -6,17 +6,19 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * 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; package org.postgresql.geometric;
import java.sql.SQLException;
import java.io.Serializable;
import org.postgresql.util.PGobject; import org.postgresql.util.PGobject;
import org.postgresql.util.PGtokenizer; import org.postgresql.util.PGtokenizer;
import org.postgresql.util.PSQLException; 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 public class PGbox extends PGobject implements Serializable, Cloneable
{ {
...@@ -78,7 +80,7 @@ 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, ','); PGtokenizer t = new PGtokenizer(value, ',');
if (t.getSize() != 2) 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[0] = new PGpoint(t.getToken(0));
point[1] = new PGpoint(t.getToken(1)); point[1] = new PGpoint(t.getToken(1));
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * 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; ...@@ -16,6 +16,8 @@ package org.postgresql.geometric;
import org.postgresql.util.PGobject; import org.postgresql.util.PGobject;
import org.postgresql.util.PGtokenizer; import org.postgresql.util.PGtokenizer;
import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLException;
import org.postgresql.util.PSQLState;
import java.io.Serializable; import java.io.Serializable;
import java.sql.SQLException; import java.sql.SQLException;
...@@ -78,7 +80,7 @@ public class PGcircle extends PGobject implements Serializable, Cloneable ...@@ -78,7 +80,7 @@ public class PGcircle extends PGobject implements Serializable, Cloneable
{ {
PGtokenizer t = new PGtokenizer(PGtokenizer.removeAngle(s), ','); PGtokenizer t = new PGtokenizer(PGtokenizer.removeAngle(s), ',');
if (t.getSize() != 2) if (t.getSize() != 2)
throw new PSQLException("postgresql.geo.circle", s); throw new PSQLException("postgresql.geo.circle", PSQLState.DATA_TYPE_MISMATCH, s);
try try
{ {
...@@ -87,7 +89,7 @@ public class PGcircle extends PGobject implements Serializable, Cloneable ...@@ -87,7 +89,7 @@ public class PGcircle extends PGobject implements Serializable, Cloneable
} }
catch (NumberFormatException e) catch (NumberFormatException e)
{ {
throw new PSQLException("postgresql.geo.circle", e); throw new PSQLException("postgresql.geo.circle", PSQLState.DATA_TYPE_MISMATCH, e);
} }
} }
......
...@@ -6,17 +6,19 @@ ...@@ -6,17 +6,19 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * 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; package org.postgresql.geometric;
import java.io.Serializable;
import java.sql.SQLException;
import org.postgresql.util.PGobject; import org.postgresql.util.PGobject;
import org.postgresql.util.PGtokenizer; import org.postgresql.util.PGtokenizer;
import org.postgresql.util.PSQLException; 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 * Currently line is not yet implemented in the backend, but this class
...@@ -77,7 +79,7 @@ public class PGline extends PGobject implements Serializable, Cloneable ...@@ -77,7 +79,7 @@ public class PGline extends PGobject implements Serializable, Cloneable
{ {
PGtokenizer t = new PGtokenizer(PGtokenizer.removeBox(s), ','); PGtokenizer t = new PGtokenizer(PGtokenizer.removeBox(s), ',');
if (t.getSize() != 2) 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[0] = new PGpoint(t.getToken(0));
point[1] = new PGpoint(t.getToken(1)); point[1] = new PGpoint(t.getToken(1));
......
...@@ -6,17 +6,19 @@ ...@@ -6,17 +6,19 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * 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; package org.postgresql.geometric;
import java.io.Serializable;
import java.sql.SQLException;
import org.postgresql.util.PGobject; import org.postgresql.util.PGobject;
import org.postgresql.util.PGtokenizer; import org.postgresql.util.PGtokenizer;
import org.postgresql.util.PSQLException; 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 public class PGlseg extends PGobject implements Serializable, Cloneable
{ {
...@@ -73,7 +75,7 @@ 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), ','); PGtokenizer t = new PGtokenizer(PGtokenizer.removeBox(s), ',');
if (t.getSize() != 2) 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[0] = new PGpoint(t.getToken(0));
point[1] = new PGpoint(t.getToken(1)); point[1] = new PGpoint(t.getToken(1));
......
...@@ -6,17 +6,19 @@ ...@@ -6,17 +6,19 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * 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; package org.postgresql.geometric;
import java.io.Serializable;
import java.sql.SQLException;
import org.postgresql.util.PGobject; import org.postgresql.util.PGobject;
import org.postgresql.util.PGtokenizer; import org.postgresql.util.PGtokenizer;
import org.postgresql.util.PSQLException; 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 public class PGpath extends PGobject implements Serializable, Cloneable
{ {
...@@ -77,7 +79,7 @@ public class PGpath extends PGobject implements Serializable, Cloneable ...@@ -77,7 +79,7 @@ public class PGpath extends PGobject implements Serializable, Cloneable
s = PGtokenizer.removePara(s); s = PGtokenizer.removePara(s);
} }
else else
throw new PSQLException("postgresql.geo.path"); throw new PSQLException("postgresql.geo.path", PSQLState.DATA_TYPE_MISMATCH);
PGtokenizer t = new PGtokenizer(s, ','); PGtokenizer t = new PGtokenizer(s, ',');
int npoints = t.getSize(); int npoints = t.getSize();
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * 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; ...@@ -15,6 +15,8 @@ package org.postgresql.geometric;
import org.postgresql.util.PGobject; import org.postgresql.util.PGobject;
import org.postgresql.util.PGtokenizer; import org.postgresql.util.PGtokenizer;
import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLException;
import org.postgresql.util.PSQLState;
import java.awt.Point; import java.awt.Point;
import java.io.Serializable; import java.io.Serializable;
import java.sql.SQLException; import java.sql.SQLException;
...@@ -80,7 +82,7 @@ public class PGpoint extends PGobject implements Serializable, Cloneable ...@@ -80,7 +82,7 @@ public class PGpoint extends PGobject implements Serializable, Cloneable
} }
catch (NumberFormatException e) catch (NumberFormatException e)
{ {
throw new PSQLException("postgresql.geo.point", e.toString()); throw new PSQLException("postgresql.geo.point", PSQLState.DATA_TYPE_MISMATCH, e.toString());
} }
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * 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 ...@@ -373,7 +373,7 @@ public abstract class AbstractJdbc1Connection implements BaseConnection
case AUTH_REQ_SCM: case AUTH_REQ_SCM:
if (Driver.logDebug) if (Driver.logDebug)
Driver.debug("postgresql: SCM"); Driver.debug("postgresql: SCM");
throw new PSQLException("postgresql.con.scm"); throw new PSQLException("postgresql.con.scm", PSQLState.CONNECTION_REJECTED);
case AUTH_REQ_PASSWORD: case AUTH_REQ_PASSWORD:
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * 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 ...@@ -211,7 +211,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
} }
catch (NumberFormatException e) 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 return 0; // SQL NULL
...@@ -565,7 +565,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet ...@@ -565,7 +565,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
Field field; Field field;
if (columnIndex < 1 || columnIndex > fields.length) 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]; field = fields[columnIndex - 1];
// some fields can be null, mainly from those returned by MetaData methods // some fields can be null, mainly from those returned by MetaData methods
...@@ -788,7 +788,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet ...@@ -788,7 +788,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
if ( this_row == null ) if ( this_row == null )
throw new PSQLException("postgresql.res.nextrequired"); throw new PSQLException("postgresql.res.nextrequired");
if ( column < 1 || column > fields.length ) if ( column < 1 || column > fields.length )
throw new PSQLException("postgresql.res.colrange" ); throw new PSQLException("postgresql.res.colrange", PSQLState.INVALID_PARAMETER_VALUE );
} }
//----------------- Formatting Methods ------------------- //----------------- Formatting Methods -------------------
......
...@@ -3,6 +3,7 @@ package org.postgresql.jdbc1; ...@@ -3,6 +3,7 @@ package org.postgresql.jdbc1;
import org.postgresql.core.Field; import org.postgresql.core.Field;
import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLException;
import org.postgresql.util.PSQLState;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Types; import java.sql.Types;
import java.util.Vector; import java.util.Vector;
...@@ -454,7 +455,7 @@ public abstract class AbstractJdbc1ResultSetMetaData ...@@ -454,7 +455,7 @@ public abstract class AbstractJdbc1ResultSetMetaData
private Field getField(int columnIndex) throws SQLException private Field getField(int columnIndex) throws SQLException
{ {
if (columnIndex < 1 || columnIndex > fields.length) 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]; return fields[columnIndex - 1];
} }
} }
......
...@@ -26,7 +26,7 @@ import java.sql.Timestamp; ...@@ -26,7 +26,7 @@ import java.sql.Timestamp;
import java.sql.Types; import java.sql.Types;
import java.util.Vector; 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 * This class defines methods of the jdbc1 specification. This class is
* extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2 * extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
* methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement * methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
...@@ -292,7 +292,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement ...@@ -292,7 +292,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
public boolean execute() throws SQLException public boolean execute() throws SQLException
{ {
if (isFunction && !returnTypeSet) if (isFunction && !returnTypeSet)
throw new PSQLException("postgresql.call.noreturntype"); throw new PSQLException("postgresql.call.noreturntype", PSQLState.STATEMENT_NOT_ALLOWED_IN_FUNCTION_CALL);
if (isFunction) if (isFunction)
{ // set entry 1 to dummy entry.. { // set entry 1 to dummy entry..
m_binds[0] = ""; // dummy entry which ensured that no one overrode m_binds[0] = ""; // dummy entry which ensured that no one overrode
...@@ -1641,9 +1641,9 @@ public abstract class AbstractJdbc1Statement implements BaseStatement ...@@ -1641,9 +1641,9 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException
{ {
if (parameterIndex != 1) if (parameterIndex != 1)
throw new PSQLException ("postgresql.call.noinout"); throw new PSQLException ("postgresql.call.noinout", PSQLState.STATEMENT_NOT_ALLOWED_IN_FUNCTION_CALL);
if (!isFunction) 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 // functionReturnType contains the user supplied value to check
// testReturn contains a modified version to make it easier to // testReturn contains a modified version to make it easier to
...@@ -1955,7 +1955,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement ...@@ -1955,7 +1955,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
private void bind(int paramIndex, Object s, String type) throws SQLException private void bind(int paramIndex, Object s, String type) throws SQLException
{ {
if (paramIndex < 1 || paramIndex > m_binds.length) 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 if (paramIndex == 1 && isFunction) // need to registerOut instead
throw new PSQLException ("postgresql.call.funcover"); throw new PSQLException ("postgresql.call.funcover");
m_binds[paramIndex - 1] = s; m_binds[paramIndex - 1] = s;
...@@ -1997,7 +1997,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement ...@@ -1997,7 +1997,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
isValid = false; isValid = false;
index = l_sql.indexOf ("call"); index = l_sql.indexOf ("call");
if (index == -1 || !isValid) 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}); new Object[]{l_sql, JDBC_SYNTAX});
l_sql = l_sql.replace ('{', ' '); // replace these characters l_sql = l_sql.replace ('{', ' '); // replace these characters
l_sql = l_sql.replace ('}', ' '); l_sql = l_sql.replace ('}', ' ');
...@@ -2027,7 +2027,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement ...@@ -2027,7 +2027,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
{ {
checkIndex (parameterIndex); checkIndex (parameterIndex);
if (type1 != this.testReturn && type2 != this.testReturn) 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, new Object[]{"java.sql.Types=" + testReturn,
getName, getName,
"java.sql.Types=" + type1}); "java.sql.Types=" + type1});
...@@ -2040,7 +2040,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement ...@@ -2040,7 +2040,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
{ {
checkIndex (parameterIndex); checkIndex (parameterIndex);
if (type != this.testReturn) 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, new Object[]{"java.sql.Types=" + testReturn,
getName, getName,
"java.sql.Types=" + type}); "java.sql.Types=" + type});
...@@ -2053,9 +2053,9 @@ public abstract class AbstractJdbc1Statement implements BaseStatement ...@@ -2053,9 +2053,9 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
private void checkIndex (int parameterIndex) throws SQLException private void checkIndex (int parameterIndex) throws SQLException
{ {
if (!isFunction) if (!isFunction)
throw new PSQLException("postgresql.call.noreturntype"); throw new PSQLException("postgresql.call.noreturntype", PSQLState.STATEMENT_NOT_ALLOWED_IN_FUNCTION_CALL);
if (parameterIndex != 1) if (parameterIndex != 1)
throw new PSQLException("postgresql.call.noinout"); throw new PSQLException("postgresql.call.noinout", PSQLState.STATEMENT_NOT_ALLOWED_IN_FUNCTION_CALL);
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * 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 ...@@ -261,7 +261,7 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
return null; return null;
if (i < 1 || i > fields.length) 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 ); return (java.sql.Array) new org.postgresql.jdbc2.Array( connection, i, fields[i - 1], this );
} }
......
...@@ -3,6 +3,7 @@ package org.postgresql.jdbc2; ...@@ -3,6 +3,7 @@ package org.postgresql.jdbc2;
import org.postgresql.core.Field; import org.postgresql.core.Field;
import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLException;
import org.postgresql.util.PSQLState;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Types; import java.sql.Types;
import java.util.Vector; import java.util.Vector;
...@@ -450,7 +451,7 @@ public abstract class AbstractJdbc2ResultSetMetaData extends org.postgresql.jdbc ...@@ -450,7 +451,7 @@ public abstract class AbstractJdbc2ResultSetMetaData extends org.postgresql.jdbc
private Field getField(int columnIndex) throws SQLException private Field getField(int columnIndex) throws SQLException
{ {
if (columnIndex < 1 || columnIndex > fields.length) 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]; return fields[columnIndex - 1];
} }
......
...@@ -5,6 +5,8 @@ import org.postgresql.core.BaseResultSet; ...@@ -5,6 +5,8 @@ import org.postgresql.core.BaseResultSet;
import org.postgresql.core.BaseStatement; import org.postgresql.core.BaseStatement;
import org.postgresql.core.Field; import org.postgresql.core.Field;
import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLException;
import org.postgresql.util.PSQLState;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
...@@ -77,7 +79,7 @@ public class Array implements java.sql.Array ...@@ -77,7 +79,7 @@ public class Array implements java.sql.Array
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
if (index < 1) if (index < 1)
throw new PSQLException("postgresql.arr.range"); throw new PSQLException("postgresql.arr.range", PSQLState.DATA_ERROR);
Object retVal = null; Object retVal = null;
ArrayList array = new ArrayList(); ArrayList array = new ArrayList();
...@@ -127,7 +129,7 @@ public class Array implements java.sql.Array ...@@ -127,7 +129,7 @@ public class Array implements java.sql.Array
count = arrayContents.length; count = arrayContents.length;
index--; index--;
if ( index + count > arrayContents.length ) if ( index + count > arrayContents.length )
throw new PSQLException("postgresql.arr.range"); throw new PSQLException("postgresql.arr.range", PSQLState.DATA_ERROR);
int i = 0; int i = 0;
switch ( getBaseType() ) switch ( getBaseType() )
......
...@@ -323,7 +323,7 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2 ...@@ -323,7 +323,7 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
*/ */
public int getSQLStateType() throws SQLException public int getSQLStateType() throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); return DatabaseMetaData.sqlStateSQL99;
} }
/** /**
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Copyright (c) 2003, PostgreSQL Global Development Group * Copyright (c) 2003, PostgreSQL Global Development Group
* *
* IDENTIFICATION * 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 ...@@ -72,7 +72,7 @@ public class PGmoney extends PGobject implements Serializable, Cloneable
} }
catch (NumberFormatException e) catch (NumberFormatException e)
{ {
throw new PSQLException("postgresql.money", e); throw new PSQLException("postgresql.money", PSQLState.NUMERIC_CONSTANT_OUT_OF_RANGE, e);
} }
} }
......
...@@ -27,21 +27,25 @@ ...@@ -27,21 +27,25 @@
// begin constant state codes // begin constant state codes
public final static PSQLState UNKNOWN_STATE = new PSQLState(""); public final static PSQLState UNKNOWN_STATE = new PSQLState("");
public final static PSQLState COMMUNICATION_ERROR = new PSQLState("08S01");
public final static PSQLState NO_DATA = new PSQLState("02000"); public final static PSQLState NO_DATA = new PSQLState("02000");
public final static PSQLState CONNECTION_FAILURE_DURING_TRANSACTION = new PSQLState("08007"); public final static PSQLState INVALID_PARAMETER_TYPE = new PSQLState("07006");
public final static PSQLState UNEXPECTED_ERROR = new PSQLState("99999"); public final static PSQLState CONNECTION_UNABLE_TO_CONNECT = new PSQLState("08001");
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_DOES_NOT_EXIST = new PSQLState("08003");
public final static PSQLState CONNECTION_REJECTED = new PSQLState("08004"); 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_FAILURE = new PSQLState("08006");
public final static PSQLState CONNECTION_CLOSED = new PSQLState("08003"); public final static PSQLState CONNECTION_FAILURE_DURING_TRANSACTION = new PSQLState("08007");
public final static PSQLState COMMUNICATION_ERROR = new PSQLState("08S01");
public final static PSQLState NOT_IMPLEMENTED = new PSQLState("0A000"); public final static PSQLState NOT_IMPLEMENTED = new PSQLState("0A000");
public final static PSQLState INVALID_PARAMETER_TYPE = new PSQLState("07006"); public final static PSQLState DATA_ERROR = new PSQLState("22000");
public final static PSQLState PARAMETER_ERROR = new PSQLState("07001"); 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 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");
} }
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