From 3d21bf82c3e27396bd3598810cbcc6f7cdc05adf Mon Sep 17 00:00:00 2001 From: Peter Mount Date: Tue, 13 Feb 2001 16:39:06 +0000 Subject: Some more including the patch to DatabaseMetaData backed out by Bruce. Tue Feb 13 16:33:00 GMT 2001 peter@retep.org.uk - More TestCases implemented. Refined the test suite api's. - Removed need for SimpleDateFormat in ResultSet.getDate() improving performance. - Rewrote ResultSet.getTime() so that it uses JDK api's better. Tue Feb 13 10:25:00 GMT 2001 peter@retep.org.uk - Added MiscTest to hold reported problems from users. - Fixed PGMoney. - JBuilder4/JDBCExplorer now works with Money fields. Patched Field & ResultSet (lots of methods) for this one. Also changed cash/money to return type DOUBLE not DECIMAL. This broke JBuilder as zero scale BigDecimal's can't have decimal places! - When a Statement is reused, the previous ResultSet is now closed. - Removed deprecated call in ResultSet.getTime() Thu Feb 08 18:53:00 GMT 2001 peter@retep.org.uk - Changed a couple of settings in DatabaseMetaData where 7.1 now supports those features - Implemented the DatabaseMetaData TestCase. Wed Feb 07 18:06:00 GMT 2001 peter@retep.org.uk - Added comment to Connection.isClosed() explaining why we deviate from the JDBC2 specification. - Fixed bug where the Isolation Level is lost while in autocommit mode. - Fixed bug where several calls to getTransactionIsolationLevel() returned the first call's result. --- src/interfaces/jdbc/org/postgresql/ResultSet.java | 52 +++++++++++++++++------ 1 file changed, 38 insertions(+), 14 deletions(-) (limited to 'src/interfaces/jdbc/org/postgresql/ResultSet.java') diff --git a/src/interfaces/jdbc/org/postgresql/ResultSet.java b/src/interfaces/jdbc/org/postgresql/ResultSet.java index cec62614ca4..bea07e639b1 100644 --- a/src/interfaces/jdbc/org/postgresql/ResultSet.java +++ b/src/interfaces/jdbc/org/postgresql/ResultSet.java @@ -25,11 +25,11 @@ public abstract class ResultSet 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. @@ -52,8 +52,8 @@ public abstract class ResultSet this.this_row = null; this.current_row = -1; } - - + + /** * Create a new ResultSet - Note that we create ResultSets to * represent the results of everything. @@ -69,7 +69,7 @@ public abstract class ResultSet { this(conn,fields,tuples,status,updateCount,0); } - + /** * We at times need to know if the resultSet we are working * with is the result of an UPDATE, DELETE or INSERT (in which @@ -83,7 +83,7 @@ public abstract class ResultSet { return (fields != null); } - + /** * Since ResultSets can be chained, we need some method of * finding the next one in the chain. The method getNext() @@ -95,7 +95,7 @@ public abstract class ResultSet { return (java.sql.ResultSet)next; } - + /** * This following method allows us to add a ResultSet object * to the end of the current chain. @@ -109,7 +109,7 @@ public abstract class ResultSet else next.append(r); } - + /** * If we are just a place holder for results, we still need * to get an updateCount. This method returns it. @@ -120,7 +120,7 @@ public abstract class ResultSet { return updateCount; } - + /** * We also need to provide a couple of auxiliary functions for * the implementation of the ResultMetaData functions. In @@ -133,7 +133,7 @@ public abstract class ResultSet { return rows.size(); } - + /** * getColumnCount returns the number of columns * @@ -143,7 +143,7 @@ public abstract class ResultSet { return fields.length; } - + /** * Returns the status message from the backend.

* It is used internally by the driver. @@ -154,7 +154,7 @@ public abstract class ResultSet { return status; } - + /** * returns the OID of a field.

* It is used internally by the driver. @@ -166,7 +166,7 @@ public abstract class ResultSet { return fields[field-1].getOID(); } - + /** * returns the OID of the last inserted row */ @@ -174,12 +174,36 @@ public abstract class ResultSet { 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 + if(s==null) + 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; + } } -- cgit v1.2.3