* Copyright (c) 2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/QueryExecutor.java,v 1.24 2003/09/08 17:30:22 barry Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/QueryExecutor.java,v 1.25 2003/09/09 10:49:16 barry Exp $
*
*-------------------------------------------------------------------------
*/
}
catch (IOException e)
{
- throw new PSQLException("postgresql.con.ioerror", e);
+ throw new PSQLException("postgresql.con.ioerror", PSQLState.CONNECTION_FAILURE_DURING_TRANSACTION, e);
}
}
}
catch (IOException e)
{
- throw new PSQLException("postgresql.con.ioerror", e);
+ throw new PSQLException("postgresql.con.ioerror", PSQLState.CONNECTION_FAILURE_DURING_TRANSACTION, e);
}
}
* Copyright (c) 2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.24 2003/09/08 17:30:22 barry Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.25 2003/09/09 10:49:16 barry Exp $
*
*-------------------------------------------------------------------------
*/
case 'N':
// Server does not support ssl
- throw new PSQLException("postgresql.con.sslnotsupported");
+ throw new PSQLException("postgresql.con.sslnotsupported", PSQLState.CONNECTION_FAILURE);
case 'S':
// Server supports ssl
break;
default:
- throw new PSQLException("postgresql.con.sslfail");
+ throw new PSQLException("postgresql.con.sslfail", PSQLState.CONNECTION_FAILURE);
}
}
}
case 'N':
// Server does not support ssl
- throw new PSQLException("postgresql.con.sslnotsupported");
+ throw new PSQLException("postgresql.con.sslnotsupported", PSQLState.CONNECTION_FAILURE);
case 'S':
// Server supports ssl
break;
default:
- throw new PSQLException("postgresql.con.sslfail");
+ throw new PSQLException("postgresql.con.sslfail", PSQLState.CONNECTION_FAILURE);
}
}
}
}
BaseResultSet result = execSQL(sql);
if (result.getColumnCount() != 1 || result.getTupleCount() != 1) {
- throw new PSQLException("postgresql.unexpected");
+ throw new PSQLException("postgresql.unexpected", PSQLState.UNEXPECTED_ERROR);
}
result.next();
pgType = result.getString(1);
}
BaseResultSet result = execSQL(sql);
if (result.getColumnCount() != 1 || result.getTupleCount() != 1)
- throw new PSQLException("postgresql.unexpected");
+ throw new PSQLException("postgresql.unexpected", PSQLState.UNEXPECTED_ERROR);
result.next();
oid = Integer.parseInt(result.getString(1));
typeOidCache.put(typeName, new Integer(oid));
import org.postgresql.core.BaseStatement;
import org.postgresql.core.Field;
import org.postgresql.util.PSQLException;
+import org.postgresql.util.PSQLState;
import org.postgresql.Driver;
public abstract class AbstractJdbc1DatabaseMetaData
String sql = "SELECT t1.typlen/t2.typlen FROM "+from+" t1.typelem=t2.oid AND t1.typname='oidvector'";
ResultSet rs = connection.createStatement().executeQuery(sql);
if (!rs.next()) {
- throw new PSQLException("postgresql.unexpected");
+ throw new PSQLException("postgresql.unexpected", PSQLState.UNEXPECTED_ERROR);
}
INDEX_MAX_KEYS = rs.getInt(1);
rs.close();
}
ResultSet rs = connection.createStatement().executeQuery(sql);
if (!rs.next()) {
- throw new PSQLException("postgresql.unexpected");
+ throw new PSQLException("postgresql.unexpected", PSQLState.UNEXPECTED_ERROR);
}
NAMEDATALEN = rs.getInt("typlen");
rs.close();
* Copyright (c) 2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.16 2003/09/08 17:30:22 barry Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.17 2003/09/09 10:49:16 barry Exp $
*
*-------------------------------------------------------------------------
*/
}
catch (NumberFormatException e)
{
- throw new PSQLException("postgresql.res.badshort", s);
+ throw new PSQLException("postgresql.res.badshort", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s);
}
}
return 0; // SQL NULL
}
catch (UnsupportedEncodingException l_uee)
{
- throw new PSQLException("postgresql.unusual", l_uee);
+ throw new PSQLException("postgresql.unusual", PSQLState.UNEXPECTED_ERROR, l_uee);
}
}
else
}
catch (UnsupportedEncodingException l_uee)
{
- throw new PSQLException("postgresql.unusual", l_uee);
+ throw new PSQLException("postgresql.unusual", PSQLState.UNEXPECTED_ERROR, l_uee);
}
}
else
}
catch (NumberFormatException e)
{
- throw new PSQLException ("postgresql.res.badint", s);
+ throw new PSQLException ("postgresql.res.badint", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s);
}
}
return 0; // SQL NULL
}
catch (NumberFormatException e)
{
- throw new PSQLException ("postgresql.res.badlong", s);
+ throw new PSQLException ("postgresql.res.badlong", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s);
}
}
return 0; // SQL NULL
}
catch (NumberFormatException e)
{
- throw new PSQLException ("postgresql.res.badbigdec", s);
+ throw new PSQLException ("postgresql.res.badbigdec", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s);
}
if (scale == -1)
return val;
}
catch (ArithmeticException e)
{
- throw new PSQLException ("postgresql.res.badbigdec", s);
+ throw new PSQLException ("postgresql.res.badbigdec", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s);
}
}
return null; // SQL NULL
}
catch (NumberFormatException e)
{
- throw new PSQLException ("postgresql.res.badfloat", s);
+ throw new PSQLException ("postgresql.res.badfloat", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s);
}
}
return 0; // SQL NULL
}
catch (NumberFormatException e)
{
- throw new PSQLException ("postgresql.res.baddouble", s);
+ throw new PSQLException ("postgresql.res.baddouble", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s);
}
}
return 0; // SQL NULL
}
catch (NumberFormatException e)
{
- throw new PSQLException("postgresql.res.baddate", s);
+ throw new PSQLException("postgresql.res.baddate",PSQLState.BAD_DATETIME_FORMAT, s);
}
}
}
catch (NumberFormatException e)
{
- throw new PSQLException("postgresql.res.badtime", s);
+ throw new PSQLException("postgresql.res.badtime", PSQLState.BAD_DATETIME_FORMAT, s);
}
}
}
catch (NumberFormatException e)
{
- throw new PSQLException("postgresql.unusual", e);
+ throw new PSQLException("postgresql.unusual", PSQLState.UNEXPECTED_ERROR, e);
}
// The nanos field stores nanoseconds. Adjust the parsed
}
catch (ParseException e)
{
- throw new PSQLException("postgresql.res.badtimestamp", PSQLState.UNKNOWN_STATE, new Integer(e.getErrorOffset()), s);
+ throw new PSQLException("postgresql.res.badtimestamp", PSQLState.BAD_DATETIME_FORMAT, new Integer(e.getErrorOffset()), s);
}
}
}
import java.sql.Types;
import java.util.Vector;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.34 2003/09/08 17:30:22 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.35 2003/09/09 10:49:16 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
while (result != null && !result.reallyResultSet())
result = (BaseResultSet) result.getNext();
if (result == null)
- throw new PSQLException("postgresql.stat.noresult");
+ throw new PSQLException("postgresql.stat.noresult", PSQLState.NO_DATA);
return (ResultSet) result;
}
if (isFunction)
{
if (!result.reallyResultSet())
- throw new PSQLException("postgresql.call.noreturnval");
+ throw new PSQLException("postgresql.call.noreturnval", PSQLState.NO_DATA);
if (!result.next ())
- throw new PSQLException ("postgresql.call.noreturnval");
+ throw new PSQLException ("postgresql.call.noreturnval", PSQLState.NO_DATA);
callResult = result.getObject(1);
int columnType = result.getMetaData().getColumnType(1);
if (columnType != functionReturnType)
}
catch (UnsupportedEncodingException l_uee)
{
- throw new PSQLException("postgresql.unusual", l_uee);
+ throw new PSQLException("postgresql.unusual", PSQLState.UNEXPECTED_ERROR, l_uee);
}
catch (IOException l_ioe)
{
- throw new PSQLException("postgresql.unusual", l_ioe);
+ throw new PSQLException("postgresql.unusual", PSQLState.UNEXPECTED_ERROR, l_ioe);
}
}
else
}
catch (UnsupportedEncodingException l_uee)
{
- throw new PSQLException("postgresql.unusual", l_uee);
+ throw new PSQLException("postgresql.unusual", PSQLState.UNEXPECTED_ERROR, l_uee);
}
catch (IOException l_ioe)
{
- throw new PSQLException("postgresql.unusual", l_ioe);
+ throw new PSQLException("postgresql.unusual", PSQLState.UNEXPECTED_ERROR, l_ioe);
}
}
else
}
catch (IOException l_ioe)
{
- throw new PSQLException("postgresql.unusual", l_ioe);
+ throw new PSQLException("postgresql.unusual", PSQLState.UNEXPECTED_ERROR, l_ioe);
}
if (l_bytesRead == length)
{
}
catch (IOException se)
{
- throw new PSQLException("postgresql.unusual", se);
+ throw new PSQLException("postgresql.unusual", PSQLState.UNEXPECTED_ERROR, se);
}
// lob is closed by the stream so don't call lob.close()
setInt(parameterIndex, oid);
}
catch (Exception e)
{
- throw new PSQLException("postgresql.format.baddate", PSQLState.UNKNOWN_STATE, s , "yyyy-MM-dd[-tz]");
+ throw new PSQLException("postgresql.format.baddate", PSQLState.BAD_DATETIME_FORMAT, s , "yyyy-MM-dd[-tz]");
}
timezone = 0;
if (timezoneLocation>7 && timezoneLocation+3 == s.length())
}
catch (Exception e)
{
- throw new PSQLException("postgresql.format.badtime", PSQLState.UNKNOWN_STATE, s, "HH:mm:ss[-tz]");
+ throw new PSQLException("postgresql.format.badtime", PSQLState.BAD_DATETIME_FORMAT, s, "HH:mm:ss[-tz]");
}
timezone = 0;
if (timezoneLocation != -1 && timezoneLocation+3 == s.length())
}
catch (Exception e)
{
- throw new PSQLException("postgresql.format.badtimestamp", PSQLState.UNKNOWN_STATE, s, "yyyy-MM-dd HH:mm:ss[.xxxxxx][-tz]");
+ throw new PSQLException("postgresql.format.badtimestamp", PSQLState.BAD_DATETIME_FORMAT, s, "yyyy-MM-dd HH:mm:ss[.xxxxxx][-tz]");
}
timezone = 0;
if (nanospos != -1)
import org.postgresql.util.PSQLException;
import org.postgresql.util.PSQLState;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Statement.java,v 1.16 2003/09/08 17:30:22 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Statement.java,v 1.17 2003/09/09 10:49:16 barry Exp $
* This class defines methods of the jdbc2 specification. This class extends
* org.postgresql.jdbc1.AbstractJdbc1Statement which provides the jdbc1
* methods. The real Statement class (for jdbc2) is org.postgresql.jdbc2.Jdbc2Statement
}
catch (IOException se)
{
- throw new PSQLException("postgresql.unusual", se);
+ throw new PSQLException("postgresql.unusual", PSQLState.UNEXPECTED_ERROR, se);
}
finally
{
}
catch (IOException l_ioe)
{
- throw new PSQLException("postgresql.unusual", l_ioe);
+ throw new PSQLException("postgresql.unusual", PSQLState.UNEXPECTED_ERROR, l_ioe);
}
setString(i, new String(l_chars, 0, l_charsRead));
}
}
catch (IOException se)
{
- throw new PSQLException("postgresql.unusual", se);
+ throw new PSQLException("postgresql.unusual", PSQLState.UNEXPECTED_ERROR, se);
}
// lob is closed by the stream so don't call lob.close()
setInt(i, oid);
}
catch (IOException se)
{
- throw new PSQLException("postgresql.unusual", se);
+ throw new PSQLException("postgresql.unusual", PSQLState.UNEXPECTED_ERROR, se);
}
// lob is closed by the stream so don't call lob.close()
setInt(i, oid);
// begin constant state codes
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 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");