diff options
Diffstat (limited to 'src/interfaces/jdbc/postgresql/jdbc2')
5 files changed, 32 insertions, 30 deletions
diff --git a/src/interfaces/jdbc/postgresql/jdbc2/Connection.java b/src/interfaces/jdbc/postgresql/jdbc2/Connection.java index 53e1bd6529..7e086435b2 100644 --- a/src/interfaces/jdbc/postgresql/jdbc2/Connection.java +++ b/src/interfaces/jdbc/postgresql/jdbc2/Connection.java @@ -17,7 +17,7 @@ import postgresql.largeobject.*; import postgresql.util.*; /** - * $Id: Connection.java,v 1.1 1999/01/17 04:51:56 momjian Exp $ + * $Id: Connection.java,v 1.2 1999/05/18 23:17:26 peter Exp $ * * A Connection represents a session with a specific database. Within the * context of a Connection, SQL statements are executed and results are @@ -96,7 +96,7 @@ public class Connection extends postgresql.Connection implements java.sql.Connec */ public java.sql.CallableStatement prepareCall(String sql) throws SQLException { - throw new SQLException("Callable Statements are not supported at this time"); + throw new PSQLException("postgresql.con.call"); // return new CallableStatement(this, sql); } @@ -311,7 +311,7 @@ public class Connection extends postgresql.Connection implements java.sql.Connec */ public void setTransactionIsolation(int level) throws SQLException { - throw new SQLException("Transaction Isolation Levels are not implemented"); + throw postgresql.Driver.notImplemented(); } /** diff --git a/src/interfaces/jdbc/postgresql/jdbc2/PreparedStatement.java b/src/interfaces/jdbc/postgresql/jdbc2/PreparedStatement.java index ef18bbaa9a..b0011aa36f 100644 --- a/src/interfaces/jdbc/postgresql/jdbc2/PreparedStatement.java +++ b/src/interfaces/jdbc/postgresql/jdbc2/PreparedStatement.java @@ -93,7 +93,7 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta for (i = 0 ; i < inStrings.length ; ++i) { if (inStrings[i] == null) - throw new SQLException("No value specified for parameter " + (i + 1)); + throw new PSQLException("postgresql.prep.param",new Integer(i + 1)); s.append (templateStrings[i]); s.append (inStrings[i]); } @@ -118,7 +118,7 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta for (i = 0 ; i < inStrings.length ; ++i) { if (inStrings[i] == null) - throw new SQLException("No value specified for parameter " + (i + 1)); + throw new PSQLException("postgresql.prep.param",new Integer(i + 1)); s.append (templateStrings[i]); s.append (inStrings[i]); } @@ -414,7 +414,7 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta */ public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException { - throw new SQLException("InputStream as parameter not supported"); + throw new PSQLException("postgresql.prep.is"); } /** @@ -489,7 +489,7 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta setString(parameterIndex, ((PGobject)x).getValue()); break; default: - throw new SQLException("Unknown Types value"); + throw new PSQLException("postgresql.prep.type"); } } @@ -553,7 +553,7 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta for (i = 0 ; i < inStrings.length ; ++i) { if (inStrings[i] == null) - throw new SQLException("No value specified for parameter " + (i + 1)); + throw new PSQLException("postgresql.prep.param",new Integer(i + 1)); s.append (templateStrings[i]); s.append (inStrings[i]); } @@ -597,7 +597,7 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta private void set(int paramIndex, String s) throws SQLException { if (paramIndex < 1 || paramIndex > inStrings.length) - throw new SQLException("Parameter index out of range"); + throw new PSQLException("postgresql.prep.range"); inStrings[paramIndex - 1] = s; } diff --git a/src/interfaces/jdbc/postgresql/jdbc2/ResultSet.java b/src/interfaces/jdbc/postgresql/jdbc2/ResultSet.java index 2be4ddba5f..0e8b661d23 100644 --- a/src/interfaces/jdbc/postgresql/jdbc2/ResultSet.java +++ b/src/interfaces/jdbc/postgresql/jdbc2/ResultSet.java @@ -144,7 +144,7 @@ public class ResultSet extends postgresql.ResultSet implements java.sql.ResultSe //return null; //return new String(bytes); if (columnIndex < 1 || columnIndex > fields.length) - throw new SQLException("Column Index out of range"); + throw new PSQLException("postgresql.res.colrange"); wasNullFlag = (this_row[columnIndex - 1] == null); if(wasNullFlag) return null; @@ -187,7 +187,7 @@ public class ResultSet extends postgresql.ResultSet implements java.sql.ResultSe { return Byte.parseByte(s); } catch (NumberFormatException e) { - throw new SQLException("Bad Byte Form: " + s); + throw new PSQLException("postgresql.res.badbyte",s); } } return 0; // SQL NULL @@ -210,7 +210,7 @@ public class ResultSet extends postgresql.ResultSet implements java.sql.ResultSe { return Short.parseShort(s); } catch (NumberFormatException e) { - throw new SQLException("Bad Short Form: " + s); + throw new PSQLException("postgresql.res.badshort",s); } } return 0; // SQL NULL @@ -233,7 +233,7 @@ public class ResultSet extends postgresql.ResultSet implements java.sql.ResultSe { return Integer.parseInt(s); } catch (NumberFormatException e) { - throw new SQLException ("Bad Integer Form: " + s); + throw new PSQLException ("postgresql.res.badint",s); } } return 0; // SQL NULL @@ -256,7 +256,7 @@ public class ResultSet extends postgresql.ResultSet implements java.sql.ResultSe { return Long.parseLong(s); } catch (NumberFormatException e) { - throw new SQLException ("Bad Long Form: " + s); + throw new PSQLException ("postgresql.res.badlong",s); } } return 0; // SQL NULL @@ -279,7 +279,7 @@ public class ResultSet extends postgresql.ResultSet implements java.sql.ResultSe { return Float.valueOf(s).floatValue(); } catch (NumberFormatException e) { - throw new SQLException ("Bad Float Form: " + s); + throw new PSQLException ("postgresql.res.badfloat",s); } } return 0; // SQL NULL @@ -302,7 +302,7 @@ public class ResultSet extends postgresql.ResultSet implements java.sql.ResultSe { return Double.valueOf(s).doubleValue(); } catch (NumberFormatException e) { - throw new SQLException ("Bad Double Form: " + s); + throw new PSQLException ("postgresql.res.baddouble",s); } } return 0; // SQL NULL @@ -329,13 +329,13 @@ public class ResultSet extends postgresql.ResultSet implements java.sql.ResultSe { val = new BigDecimal(s); } catch (NumberFormatException e) { - throw new SQLException ("Bad BigDecimal Form: " + s); + throw new PSQLException ("postgresql.res.badbigdec",s); } try { return val.setScale(scale); } catch (ArithmeticException e) { - throw new SQLException ("Bad BigDecimal Form: " + s); + throw new PSQLException ("postgresql.res.badbigdec",s); } } return null; // SQL NULL @@ -359,7 +359,7 @@ public class ResultSet extends postgresql.ResultSet implements java.sql.ResultSe public byte[] getBytes(int columnIndex) throws SQLException { if (columnIndex < 1 || columnIndex > fields.length) - throw new SQLException("Column Index out of range"); + throw new PSQLException("postgresql.res.colrange"); wasNullFlag = (this_row[columnIndex - 1] == null); // Handle OID's as BLOBS @@ -392,7 +392,7 @@ public class ResultSet extends postgresql.ResultSet implements java.sql.ResultSe try { return new java.sql.Date(df.parse(s).getTime()); } catch (ParseException e) { - throw new SQLException("Bad Date Format: at " + e.getErrorOffset() + " in " + s); + throw new PSQLException("postgresql.res.baddate",new Integer(e.getErrorOffset()),s); } } @@ -419,7 +419,7 @@ public class ResultSet extends postgresql.ResultSet implements java.sql.ResultSe int sec = (s.length() == 5) ? 0 : Integer.parseInt(s.substring(6)); return new Time(hr, min, sec); } catch (NumberFormatException e) { - throw new SQLException ("Bad Time Form: " + s); + throw new PSQLException ("postgresql.res.badtime",s); } } return null; // SQL NULL @@ -450,7 +450,7 @@ public class ResultSet extends postgresql.ResultSet implements java.sql.ResultSe java.util.Date d = df.parse(s); return new Timestamp(d.getTime()); } catch (ParseException e) { - throw new SQLException("Bad Timestamp Format: at " + e.getErrorOffset() + " in " + s); + throw new PSQLException("postgresql.res.badtimestamp",new Integer(e.getErrorOffset()),s); } } return null; // SQL NULL @@ -711,7 +711,7 @@ public class ResultSet extends postgresql.ResultSet implements java.sql.ResultSe Field field; if (columnIndex < 1 || columnIndex > fields.length) - throw new SQLException("Column index out of range"); + throw new PSQLException("postgresql.res.colrange"); field = fields[columnIndex - 1]; // some fields can be null, mainly from those returned by MetaData methods @@ -784,7 +784,7 @@ public class ResultSet extends postgresql.ResultSet implements java.sql.ResultSe for (i = 0 ; i < fields.length; ++i) if (fields[i].name.equalsIgnoreCase(columnName)) return (i+1); - throw new SQLException ("Column name not found"); + throw new PSQLException ("postgresql.res.colname",columnName); } // ** JDBC 2 Extensions ** diff --git a/src/interfaces/jdbc/postgresql/jdbc2/ResultSetMetaData.java b/src/interfaces/jdbc/postgresql/jdbc2/ResultSetMetaData.java index 8ac88b905f..84aeafec65 100644 --- a/src/interfaces/jdbc/postgresql/jdbc2/ResultSetMetaData.java +++ b/src/interfaces/jdbc/postgresql/jdbc2/ResultSetMetaData.java @@ -9,6 +9,7 @@ import java.lang.*; import java.sql.*; import java.util.*; import postgresql.*; +import postgresql.util.*; /** * A ResultSetMetaData object can be used to find out about the types and @@ -419,7 +420,7 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData private Field getField(int columnIndex) throws SQLException { if (columnIndex < 1 || columnIndex > fields.length) - throw new SQLException("Column index out of range"); + throw new PSQLException("postgresql.res.colrange"); return fields[columnIndex - 1]; } diff --git a/src/interfaces/jdbc/postgresql/jdbc2/Statement.java b/src/interfaces/jdbc/postgresql/jdbc2/Statement.java index 4c9c8c9e01..26011ba765 100644 --- a/src/interfaces/jdbc/postgresql/jdbc2/Statement.java +++ b/src/interfaces/jdbc/postgresql/jdbc2/Statement.java @@ -7,6 +7,7 @@ package postgresql.jdbc2; import java.sql.*; import java.util.Vector; +import postgresql.util.*; /** * A Statement object is used for executing a static SQL statement and @@ -54,7 +55,7 @@ public class Statement implements java.sql.Statement while (result != null && !((postgresql.ResultSet)result).reallyResultSet()) result = ((postgresql.ResultSet)result).getNext(); if (result == null) - throw new SQLException("no results returned"); + throw new PSQLException("postgresql.stat.noresult"); return result; } @@ -71,7 +72,7 @@ public class Statement implements java.sql.Statement { this.execute(sql); if (((postgresql.ResultSet)result).reallyResultSet()) - throw new SQLException("results returned"); + throw new PSQLException("postgresql.stat.result"); return this.getUpdateCount(); } @@ -116,7 +117,7 @@ public class Statement implements java.sql.Statement */ public void setMaxFieldSize(int max) throws SQLException { - throw new SQLException("Attempt to setMaxFieldSize failed - compile time default"); + throw new PSQLException("postgresql.stat.maxfieldsize"); } /** @@ -341,7 +342,7 @@ public class Statement implements java.sql.Statement public int[] executeBatch() throws SQLException { if(batch==null || batch.isEmpty()) - throw new SQLException("The batch is empty."); + throw new PSQLException("postgresql.stat.batch.empty"); int size=batch.size(); int[] result=new int[size]; @@ -353,7 +354,7 @@ public class Statement implements java.sql.Statement this.execute("commit"); // PTM: check this } catch(SQLException e) { this.execute("abort"); // PTM: check this - throw new SQLException("The result "+i+" \""+batch.elementAt(i)+"\" aborted."); + throw new PSQLException("postgresql.stat.batch.error",new Integer(i),batch.elementAt(i)); } return result; } |
