diff options
author | Barry Lind <barry@xythos.com> | 2002-07-23 03:59:55 +0000 |
---|---|---|
committer | Barry Lind <barry@xythos.com> | 2002-07-23 03:59:55 +0000 |
commit | 1e3187366ca96069e71527cf109198f645e14252 (patch) | |
tree | 4a962e3adecaeb680f4366c611af5ceaca763944 /src/interfaces/jdbc/org/postgresql/ResultSet.java | |
parent | e9c013f4bddd953df03be74177a37016d1e22b96 (diff) |
Initial restructuring to add jdbc3 support. There was a significant amount
of duplicated code between the jdbc1 and jdbc2. This checkin restructures
the code so that the duplication is removed so that the jdbc3 support
can be added without adding yet another copy of everything. Also many
classes were renamed to avoid confusion with multiple different objects
having the same name. The timestamp tests were also updated to add support
for testing timestamp without time zone in addition to timestamp with time zone
Modified Files:
jdbc/Makefile jdbc/build.xml jdbc/example/ImageViewer.java
jdbc/example/basic.java jdbc/example/blobtest.java
jdbc/example/threadsafe.java
jdbc/org/postgresql/Driver.java.in
jdbc/org/postgresql/Field.java
jdbc/org/postgresql/core/QueryExecutor.java
jdbc/org/postgresql/fastpath/Fastpath.java
jdbc/org/postgresql/jdbc1/CallableStatement.java
jdbc/org/postgresql/jdbc1/DatabaseMetaData.java
jdbc/org/postgresql/jdbc1/PreparedStatement.java
jdbc/org/postgresql/jdbc2/Array.java
jdbc/org/postgresql/jdbc2/CallableStatement.java
jdbc/org/postgresql/jdbc2/DatabaseMetaData.java
jdbc/org/postgresql/jdbc2/PreparedStatement.java
jdbc/org/postgresql/jdbc2/UpdateableResultSet.java
jdbc/org/postgresql/largeobject/LargeObjectManager.java
jdbc/org/postgresql/largeobject/PGblob.java
jdbc/org/postgresql/largeobject/PGclob.java
jdbc/org/postgresql/test/jdbc2/BlobTest.java
jdbc/org/postgresql/test/jdbc2/ConnectionTest.java
jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
jdbc/org/postgresql/test/jdbc2/TimestampTest.java
jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
jdbc/org/postgresql/util/Serialize.java
Added Files:
jdbc/org/postgresql/PGConnection.java
jdbc/org/postgresql/PGStatement.java
jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java
jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java
jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
jdbc/org/postgresql/jdbc1/Jdbc1Connection.java
jdbc/org/postgresql/jdbc1/Jdbc1ResultSet.java
jdbc/org/postgresql/jdbc1/Jdbc1Statement.java
jdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java
jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java
jdbc/org/postgresql/jdbc2/Jdbc2Connection.java
jdbc/org/postgresql/jdbc2/Jdbc2ResultSet.java
jdbc/org/postgresql/jdbc2/Jdbc2Statement.java
Removed Files:
jdbc/org/postgresql/Connection.java
jdbc/org/postgresql/ResultSet.java
jdbc/org/postgresql/Statement.java
jdbc/org/postgresql/jdbc1/Connection.java
jdbc/org/postgresql/jdbc1/ResultSet.java
jdbc/org/postgresql/jdbc1/Statement.java
jdbc/org/postgresql/jdbc2/Connection.java
jdbc/org/postgresql/jdbc2/ResultSet.java
jdbc/org/postgresql/jdbc2/Statement.java
Diffstat (limited to 'src/interfaces/jdbc/org/postgresql/ResultSet.java')
-rw-r--r-- | src/interfaces/jdbc/org/postgresql/ResultSet.java | 264 |
1 files changed, 0 insertions, 264 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/ResultSet.java b/src/interfaces/jdbc/org/postgresql/ResultSet.java deleted file mode 100644 index 6e533eed010..00000000000 --- a/src/interfaces/jdbc/org/postgresql/ResultSet.java +++ /dev/null @@ -1,264 +0,0 @@ -package org.postgresql; - -import java.lang.*; -import java.io.*; -import java.math.*; -import java.text.*; -import java.util.*; -import java.sql.*; -import org.postgresql.largeobject.*; -import org.postgresql.util.*; - -/* - * This class implements the common internal methods used by both JDBC 1 and - * JDBC 2 specifications. - */ -public abstract class ResultSet -{ - protected Vector rows; // The results - protected Field fields[]; // The field descriptions - protected String status; // Status of the result - protected boolean binaryCursor = false; // is the data binary or Strings - protected int updateCount; // How many rows did we get back? - protected long insertOID; // The oid of an inserted row - protected int current_row; // Our pointer to where we are at - protected byte[][] this_row; // the current row result - protected Connection connection; // the connection which we returned from - protected SQLWarning warnings = null; // The warning chain - protected boolean wasNullFlag = false; // the flag for wasNull() - - // We can chain multiple resultSets together - this points to - // next resultSet in the chain. - protected ResultSet next = null; - - /* - * Create a new ResultSet - Note that we create ResultSets to - * represent the results of everything. - * - * @param fields an array of Field objects (basically, the - * ResultSet MetaData) - * @param tuples Vector of the actual data - * @param status the status string returned from the back end - * @param updateCount the number of rows affected by the operation - * @param cursor the positioned update/delete cursor name - */ - public ResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) - { - this.connection = conn; - this.fields = fields; - this.rows = tuples; - this.status = status; - this.updateCount = updateCount; - this.insertOID = insertOID; - this.this_row = null; - this.current_row = -1; - this.binaryCursor = binaryCursor; - } - - - /* - * Create a new ResultSet - Note that we create ResultSets to - * represent the results of everything. - * - * @param fields an array of Field objects (basically, the - * ResultSet MetaData) - * @param tuples Vector of the actual data - * @param status the status string returned from the back end - * @param updateCount the number of rows affected by the operation - * @param cursor the positioned update/delete cursor name - */ - public ResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount) - { - this(conn, fields, tuples, status, updateCount, 0, false); - } - - /* - * We at times need to know if the resultSet we are working - * with is the result of an UPDATE, DELETE or INSERT (in which - * case, we only have a row count), or of a SELECT operation - * (in which case, we have multiple fields) - this routine - * tells us. - * - * @return true if we have tuples available - */ - public boolean reallyResultSet() - { - return (fields != null); - } - - /* - * Since ResultSets can be chained, we need some method of - * finding the next one in the chain. The method getNext() - * returns the next one in the chain. - * - * @return the next ResultSet, or null if there are none - */ - public java.sql.ResultSet getNext() - { - return (java.sql.ResultSet)next; - } - - /* - * This following method allows us to add a ResultSet object - * to the end of the current chain. - * - * @param r the resultset to add to the end of the chain. - */ - public void append(ResultSet r) - { - if (next == null) - next = r; - else - next.append(r); - } - - /* - * If we are just a place holder for results, we still need - * to get an updateCount. This method returns it. - * - * @return the updateCount - */ - public int getResultCount() - { - return updateCount; - } - - /* - * We also need to provide a couple of auxiliary functions for - * the implementation of the ResultMetaData functions. In - * particular, we need to know the number of rows and the - * number of columns. Rows are also known as Tuples - * - * @return the number of rows - */ - public int getTupleCount() - { - return rows.size(); - } - - /* - * getColumnCount returns the number of columns - * - * @return the number of columns - */ - public int getColumnCount() - { - return fields.length; - } - - /* - * Returns the status message from the backend.<p> - * It is used internally by the driver. - * - * @return the status string from the backend - */ - public String getStatusString() - { - return status; - } - - /* - * returns the OID of a field.<p> - * It is used internally by the driver. - * - * @param field field id - * @return the oid of that field's type - */ - public int getColumnOID(int field) - { - return fields[field -1].getOID(); - } - - /* - * returns the OID of the last inserted row. Deprecated in 7.2 because - * range for OID values is greater than java signed int. - * @deprecated Replaced by getLastOID() in 7.2 - */ - public int getInsertedOID() - { - return (int) getLastOID(); - } - - - /* - * returns the OID of the last inserted row - * @since 7.2 - */ - public long getLastOID() - { - return insertOID; - } - - /* - * This is part of the JDBC API, but is required by org.postgresql.Field - */ - public abstract void close() throws SQLException; - public abstract boolean next() throws SQLException; - public abstract String getString(int i) throws SQLException; - - /* - * This is used to fix get*() methods on Money fields. It should only be - * used by those methods! - * - * It converts ($##.##) to -##.## and $##.## to ##.## - */ - public String getFixedString(int col) throws SQLException - { - String s = getString(col); - - // Handle SQL Null - wasNullFlag = (this_row[col - 1] == null); - if (wasNullFlag) - return null; - - // Handle Money - if (s.charAt(0) == '(') - { - s = "-" + org.postgresql.util.PGtokenizer.removePara(s).substring(1); - } - if (s.charAt(0) == '$') - { - s = s.substring(1); - } - - return s; - } - - /** - * The first warning reported by calls on this ResultSet is - * returned. Subsequent ResultSet warnings will be chained - * to this SQLWarning. - * - * <p>The warning chain is automatically cleared each time a new - * row is read. - * - * <p><B>Note:</B> This warning chain only covers warnings caused by - * ResultSet methods. Any warnings caused by statement methods - * (such as reading OUT parameters) will be chained on the - * Statement object. - * - * @return the first SQLWarning or null; - * @exception SQLException if a database access error occurs. - */ - public SQLWarning getWarnings() throws SQLException - { - return warnings; - } - - /** - * Add a warning chain to the current warning chain - * @param warnings warnings to add - */ - public void addWarnings(SQLWarning warnings) { - if ( this.warnings != null ) - this.warnings.setNextWarning(warnings); - else - this.warnings = warnings; - } - protected void checkResultSet( int column ) throws SQLException - { - if ( this_row == null ) throw new PSQLException("postgresql.res.nextrequired"); - if ( column < 1 || column > fields.length ) throw new PSQLException("postgresql.res.colrange" ); - } -} - |