db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davi...@apache.org
Subject svn commit: r371561 [3/11] - in /db/derby/code/trunk/java: client/org/apache/derby/client/ client/org/apache/derby/client/am/ client/org/apache/derby/client/net/ client/org/apache/derby/jdbc/ testing/org/apache/derbyTesting/functionTests/master/DerbyNe...
Date Mon, 23 Jan 2006 15:58:53 GMT
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Clob.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/Clob.java?rev=371561&r1=371560&r2=371561&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Clob.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Clob.java Mon Jan 23 07:58:34 2006
@@ -20,6 +20,8 @@
 
 package org.apache.derby.client.am;
 
+import java.sql.SQLException;
+
 public class Clob extends Lob implements java.sql.Clob {
     //---------------------navigational members-----------------------------------
 
@@ -133,65 +135,93 @@
 
     // ---------------------------jdbc 2------------------------------------------
     // Create another method lengthX for internal calls
-    public long length() throws SqlException {
-        synchronized (agent_.connection_) {
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceEntry(this, "length");
-            }
-
-            if (lengthObtained_) {
+    public long length() throws SQLException {
+        try
+        {
+            synchronized (agent_.connection_) {
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceEntry(this, "length");
+                }
+
+                if (lengthObtained_) {
+                    return sqlLength_;
+                }
+
+                lengthInBytes_ = super.sqlLength();
+
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceExit(this, "length", sqlLength_);
+                }
                 return sqlLength_;
             }
-
-            lengthInBytes_ = super.sqlLength();
-
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceExit(this, "length", sqlLength_);
-            }
-            return sqlLength_;
+        }
+        catch ( SqlException se )
+        {
+            throw se.getSQLException();
         }
     }
 
-    public String getSubString(long pos, int length) throws SqlException {
-        synchronized (agent_.connection_) {
-            String retVal = null;
+    public String getSubString(long pos, int length) throws SQLException {
+        try
+        {
+            synchronized (agent_.connection_) {
+                String retVal = null;
 
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceEntry(this, "getSubString", (int) pos, length);
-            }
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceEntry(this, "getSubString", (int) pos, length);
+                }
 
-            // We can also do a check for pos > length()
-            // Defer it till FP7 so that proper testing can be performed on this
-            if ((pos <= 0) || (length < 0)) {
-                throw new SqlException(agent_.logWriter_, "Invalid position " + pos + " or length " + length);
-            }
+                // We can also do a check for pos > length()
+                // Defer it till FP7 so that proper testing can be performed on this
+                if ((pos <= 0) || (length < 0)) {
+                    throw new SqlException(agent_.logWriter_, "Invalid position " + pos + " or length " + length);
+                }
 
-            retVal = getSubStringX(pos, length);
+                retVal = getSubStringX(pos, length);
 
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceExit(this, "getSubString", retVal);
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceExit(this, "getSubString", retVal);
+                }
+                return retVal;
             }
-            return retVal;
+        }
+        catch ( SqlException se )
+        {
+            throw se.getSQLException();
         }
     }
 
     private String getSubStringX(long pos, int length) throws SqlException {
-        checkForClosedConnection();
-        long actualLength = Math.min(this.length() - pos + 1, (long) length);
-        return string_.substring((int) pos - 1, (int) (pos - 1 + actualLength));
+        try
+        {
+            checkForClosedConnection();
+            long actualLength = Math.min(this.length() - pos + 1, (long) length);
+            return string_.substring((int) pos - 1, (int) (pos - 1 + actualLength));
+        }
+        catch ( SQLException se )
+        {
+            throw new SqlException(se);
+        }
     }
 
-    public java.io.Reader getCharacterStream() throws SqlException {
-        synchronized (agent_.connection_) {
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceEntry(this, "getCharacterStream");
-            }
-
-            java.io.Reader retVal = getCharacterStreamX();
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceExit(this, "getCharacterStream", retVal);
+    public java.io.Reader getCharacterStream() throws SQLException {
+        try
+        {
+            synchronized (agent_.connection_) {
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceEntry(this, "getCharacterStream");
+                }
+
+                java.io.Reader retVal = getCharacterStreamX();
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceExit(this, "getCharacterStream", retVal);
+                }
+                return retVal;
             }
-            return retVal;
+        }
+        catch ( SqlException se )
+        {
+            throw se.getSQLException();
         }
     }
 
@@ -206,17 +236,24 @@
         return new java.io.StringReader(string_);
     }
 
-    public java.io.InputStream getAsciiStream() throws SqlException {
-        synchronized (agent_.connection_) {
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceEntry(this, "getAsciiStream");
-            }
-
-            java.io.InputStream retVal = getAsciiStreamX();
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceExit(this, "getAsciiStream", retVal);
+    public java.io.InputStream getAsciiStream() throws SQLException {
+        try
+        {
+            synchronized (agent_.connection_) {
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceEntry(this, "getAsciiStream");
+                }
+
+                java.io.InputStream retVal = getAsciiStreamX();
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceExit(this, "getAsciiStream", retVal);
+                }
+                return retVal;
             }
-            return retVal;
+        }
+        catch ( SqlException se )
+        {
+            throw se.getSQLException();
         }
     }
 
@@ -231,23 +268,30 @@
         return new AsciiStream(string_, new java.io.StringReader(string_));
     }
 
-    public long position(String searchstr, long start) throws SqlException {
-        synchronized (agent_.connection_) {
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceEntry(this,
-                        "position(String, long)",
-                        searchstr,
-                        start);
-            }
-            if (searchstr == null) {
-                throw new SqlException(agent_.logWriter_, "Search string cannot be null.");
-            }
-
-            long pos = positionX(searchstr, start);
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceExit(this, "position(String, long)", pos);
+    public long position(String searchstr, long start) throws SQLException {
+        try
+        {
+            synchronized (agent_.connection_) {
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceEntry(this,
+                            "position(String, long)",
+                            searchstr,
+                            start);
+                }
+                if (searchstr == null) {
+                    throw new SqlException(agent_.logWriter_, "Search string cannot be null.");
+                }
+
+                long pos = positionX(searchstr, start);
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceExit(this, "position(String, long)", pos);
+                }
+                return pos;
             }
-            return pos;
+        }
+        catch ( SqlException se )
+        {
+            throw se.getSQLException();
         }
     }
 
@@ -266,22 +310,29 @@
         return (long) index;
     }
 
-    public long position(java.sql.Clob searchstr, long start) throws SqlException {
-        synchronized (agent_.connection_) {
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceEntry(this,
-                        "position(Clob, long)",
-                        searchstr,
-                        start);
-            }
-            if (searchstr == null) {
-                throw new SqlException(agent_.logWriter_, "Search string cannot be null.");
-            }
-            long pos = positionX(searchstr, start);
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceExit(this, "position(Clob, long)", pos);
+    public long position(java.sql.Clob searchstr, long start) throws SQLException {
+        try
+        {
+            synchronized (agent_.connection_) {
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceEntry(this,
+                            "position(Clob, long)",
+                            searchstr,
+                            start);
+                }
+                if (searchstr == null) {
+                    throw new SqlException(agent_.logWriter_, "Search string cannot be null.");
+                }
+                long pos = positionX(searchstr, start);
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceExit(this, "position(Clob, long)", pos);
+                }
+                return pos;
             }
-            return pos;
+        }
+        catch ( SqlException se )
+        {
+            throw se.getSQLException();
         }
     }
 
@@ -311,29 +362,43 @@
 
     //---------------------------- jdbc 3.0 -----------------------------------
 
-    public int setString(long pos, String str) throws SqlException {
-        synchronized (agent_.connection_) {
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceEntry(this, "setString", (int) pos, str);
-            }
-            int length = setStringX(pos, str, 0, str.length());
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceExit(this, "setString", length);
+    public int setString(long pos, String str) throws SQLException {
+        try
+        {
+            synchronized (agent_.connection_) {
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceEntry(this, "setString", (int) pos, str);
+                }
+                int length = setStringX(pos, str, 0, str.length());
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceExit(this, "setString", length);
+                }
+                return length;
             }
-            return length;
+        }
+        catch ( SqlException se )
+        {
+            throw se.getSQLException();
         }
     }
 
-    public int setString(long pos, String str, int offset, int len) throws SqlException {
-        synchronized (agent_.connection_) {
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceEntry(this, "setString", (int) pos, str, offset, len);
-            }
-            int length = setStringX(pos, str, offset, len);
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceExit(this, "setString", length);
+    public int setString(long pos, String str, int offset, int len) throws SQLException {
+        try
+        {
+            synchronized (agent_.connection_) {
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceEntry(this, "setString", (int) pos, str, offset, len);
+                }
+                int length = setStringX(pos, str, offset, len);
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceExit(this, "setString", length);
+                }
+                return length;
             }
-            return length;
+        }
+        catch ( SqlException se )
+        {
+            throw se.getSQLException();
         }
     }
 
@@ -361,51 +426,72 @@
         return length;
     }
 
-    public java.io.OutputStream setAsciiStream(long pos) throws SqlException {
-        synchronized (agent_.connection_) {
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceEntry(this, "setAsciiStream", (int) pos);
-            }
-            ClobOutputStream outStream = new ClobOutputStream(this, pos);
-
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceExit(this, "setAsciiStream", outStream);
+    public java.io.OutputStream setAsciiStream(long pos) throws SQLException {
+        try
+        {
+            synchronized (agent_.connection_) {
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceEntry(this, "setAsciiStream", (int) pos);
+                }
+                ClobOutputStream outStream = new ClobOutputStream(this, pos);
+
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceExit(this, "setAsciiStream", outStream);
+                }
+                return outStream;
             }
-            return outStream;
+        }
+        catch ( SqlException se )
+        {
+            throw se.getSQLException();
         }
     }
 
-    public java.io.Writer setCharacterStream(long pos) throws SqlException {
-        synchronized (agent_.connection_) {
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceEntry(this, "setCharacterStream", (int) pos);
-            }
-            ClobWriter writer = new ClobWriter(this, pos);
-
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceExit(this, "setCharacterStream", writer);
+    public java.io.Writer setCharacterStream(long pos) throws SQLException {
+        try
+        {
+            synchronized (agent_.connection_) {
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceEntry(this, "setCharacterStream", (int) pos);
+                }
+                ClobWriter writer = new ClobWriter(this, pos);
+
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceExit(this, "setCharacterStream", writer);
+                }
+                return writer;
             }
-            return writer;
+        }
+        catch ( SqlException se )
+        {
+            throw se.getSQLException();
         }
     }
 
-    public void truncate(long len) throws SqlException {
-        synchronized (agent_.connection_) {
-            if (agent_.loggingEnabled()) {
-                agent_.logWriter_.traceEntry(this, " truncate", (int) len);
-            }
-            if (len < 0 || len > this.length()) {
-                throw new SqlException(agent_.logWriter_, "Invalid length " + len);
-            }
-            if (len == this.length()) {
-                return;
+    public void truncate(long len) throws SQLException {
+        try
+        {
+            synchronized (agent_.connection_) {
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceEntry(this, " truncate", (int) len);
+                }
+                if (len < 0 || len > this.length()) {
+                    throw new SqlException(agent_.logWriter_, "Invalid length " + len);
+                }
+                if (len == this.length()) {
+                    return;
+                }
+                String newstr = string_.substring(0, (int) len);
+                string_ = newstr;
+                asciiStream_ = new java.io.StringBufferInputStream(string_);
+                unicodeStream_ = new java.io.StringBufferInputStream(string_);
+                characterStream_ = new java.io.StringReader(string_);
+                sqlLength_ = string_.length();
             }
-            String newstr = string_.substring(0, (int) len);
-            string_ = newstr;
-            asciiStream_ = new java.io.StringBufferInputStream(string_);
-            unicodeStream_ = new java.io.StringBufferInputStream(string_);
-            characterStream_ = new java.io.StringReader(string_);
-            sqlLength_ = string_.length();
+        }
+        catch ( SqlException se )
+        {
+            throw se.getSQLException();
         }
     }
 
@@ -490,12 +576,12 @@
 
     // this method is primarily for mixed clob length calculations.
     // it was introduced to prevent recursion in the actual char length calculation
-    public long getByteLength() throws SqlException {
-        if (lengthObtained_ == true) {
-            return lengthInBytes_;
-        }
+    public long getByteLength() throws SQLException {
+            if (lengthObtained_ == true) {
+                return lengthInBytes_;
+            }
 
-        length();
-        return lengthInBytes_;
+            length();
+            return lengthInBytes_;
     }
 }

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ColumnMetaData.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/ColumnMetaData.java?rev=371561&r1=371560&r2=371561&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ColumnMetaData.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ColumnMetaData.java Mon Jan 23 07:58:34 2006
@@ -20,6 +20,8 @@
 
 package org.apache.derby.client.am;
 
+import java.sql.SQLException;
+
 import org.apache.derby.iapi.reference.DRDAConstants;
 import org.apache.derby.iapi.reference.JDBC30Translation;
 
@@ -155,223 +157,321 @@
 
     // ---------------------------jdbc 1------------------------------------------
 
-    public int getColumnCount() throws SqlException {
-        checkForClosedStatement();
-        return columns_;
-    }
-
-    public boolean isAutoIncrement(int column) throws SqlException {
-        checkForClosedStatement();
-        checkForValidColumnIndex(column);
-        return false;
-    }
-
-    public boolean isCaseSensitive(int column) throws SqlException {
-        checkForClosedStatement();
-        checkForValidColumnIndex(column);
-        //return true if the SQLTYPE is CHAR, VARCHAR, LOGVARCHAR or CLOB
-        int type = types_[column - 1];
-        return
-                type == Types.CHAR ||
-                type == Types.VARCHAR ||
-                type == Types.LONGVARCHAR ||
-                type == Types.CLOB;
+    public int getColumnCount() throws SQLException {
+        try
+        {            
+            checkForClosedStatement();
+            return columns_;
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
+        }
+    }
+
+    public boolean isAutoIncrement(int column) throws SQLException {
+        try
+        {
+            checkForClosedStatement();
+            checkForValidColumnIndex(column);
+            return false;
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
+        }
+    }
+
+    public boolean isCaseSensitive(int column) throws SQLException {
+        try
+        {
+            checkForClosedStatement();
+            checkForValidColumnIndex(column);
+            //return true if the SQLTYPE is CHAR, VARCHAR, LOGVARCHAR or CLOB
+            int type = types_[column - 1];
+            return
+                    type == Types.CHAR ||
+                    type == Types.VARCHAR ||
+                    type == Types.LONGVARCHAR ||
+                    type == Types.CLOB;
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
+        }
     }
 
     // all searchable except distinct
-    public boolean isSearchable(int column) throws SqlException {
-        checkForClosedStatement();
-        checkForValidColumnIndex(column);
-        return true;
-    }
-
-    public boolean isCurrency(int column) throws SqlException {
-        checkForClosedStatement();
-        checkForValidColumnIndex(column);
-        return false;
-    }
-
-    public int isNullable(int column) throws SqlException {
-        checkForClosedStatement();
-        checkForValidColumnIndex(column);
-        if (nullable_[column - 1]) {
-            return java.sql.ResultSetMetaData.columnNullable;
-        } else {
-            return java.sql.ResultSetMetaData.columnNoNulls;
-        }
-    }
-
-    public boolean isSigned(int column) throws SqlException {
-        checkForClosedStatement();
-        checkForValidColumnIndex(column);
-        //return true only if the SQLType is SMALLINT, INT, BIGINT, FLOAT, REAL, DOUBLE, NUMERIC OR DECIMAL
-        int type = types_[column - 1];
-        return
-                type == Types.SMALLINT ||
-                type == Types.INTEGER ||
-                type == Types.BIGINT ||
-                type == java.sql.Types.FLOAT ||
-                type == Types.REAL ||
-                type == Types.DOUBLE ||
-                type == java.sql.Types.NUMERIC ||
-                type == Types.DECIMAL;
-    }
-
-    public int getColumnDisplaySize(int column) throws SqlException {
-        checkForClosedStatement();
-        checkForValidColumnIndex(column);
-        int jdbcType = types_[column - 1];
-        switch (jdbcType) {
-        case Types.BOOLEAN:
-            return 5;
-        case Types.INTEGER:
-            return 11;
-        case Types.SMALLINT:
-            return 6;
-        case Types.BIGINT:
-            return 20;
-        case Types.REAL:
-            return 13;
-        case Types.DOUBLE:
-        case java.sql.Types.FLOAT:
-            return 22;
-        case Types.DECIMAL:
-        case java.sql.Types.NUMERIC:
-            return getPrecision(column) + 2;  // add 1 for sign and 1 for decimal
-        case Types.CHAR:
-        case Types.VARCHAR:
-        case Types.LONGVARCHAR:
-        case Types.CLOB:
-            return (int) sqlLength_[column - 1];
-        case Types.DATE:
-            return 10;
-        case Types.TIME:
-            return 8;
-        case Types.TIMESTAMP:
-            return 26;
-        case Types.BINARY:
-        case Types.VARBINARY:
-        case Types.LONGVARBINARY:
-        case Types.BLOB:
-            return (int) (2 * sqlLength_[column - 1]); // eg. "FF" represents just one byte
-        default:
-            throw new SqlException(logWriter_, "not supported");
-        }
-    }
-
-    public String getColumnLabel(int column) throws SqlException {
-        checkForClosedStatement();
-        checkForValidColumnIndex(column);
-        // return labels if label is turned on, otherwise, return column name
-        if (sqlLabel_ != null && sqlLabel_[column - 1] != null) {
-            return sqlLabel_[column - 1];
-        }
-        if (sqlName_ == null || sqlName_[column - 1] == null) {
-            assignColumnName(column);
-        }
-        return sqlName_[column - 1];
-    }
-
-    public String getColumnName(int column) throws SqlException {
-        checkForClosedStatement();
-        checkForValidColumnIndex(column);
-        // The Javadoc and Jdbc book explicitly state that the empty string ("") is returned if "not applicable"
-        // for the following methods:
-        //   getSchemaName()
-        //   getTableName()
-        //   getCatalogName()
-        // Since the empty string is a valid string and is not really a proper table name, schema name, or catalog name,
-        // we're not sure why the empty string was chosen over null, except possibly to be friendly to lazy jdbc apps
-        // that may not be checking for nulls, thereby minimizing potential NPE's.
-        // By induction, it would make sense to return the empty string when column name is not available/applicable.
-        //
-        // The JDBC specification contains blanket statements about SQL compliance levels,
-        // so elaboration within the JDBC specification is often bypassed.
-        // Personally, I would prefer to return Java null for all the not-applicable cases,
-        // but it appears that we have precedent for the empty ("") string.
-        //
-        // We assume a straightforward induction from jdbc spec that the column name be "" (empty)
-        // in preference to null or NULL for the not applicable case.
-        //
-        if (sqlName_ == null || sqlName_[column - 1] == null) {
-            assignColumnName(column);
-        }
-        return sqlName_[column - 1];
-    }
-
-    public String getSchemaName(int column) throws SqlException {
-        checkForClosedStatement();
-        checkForValidColumnIndex(column);
-        if (sqlxSchema_ == null || sqlxSchema_[column - 1] == null) {
-            return ""; // Per jdbc spec
-        }
-        return sqlxSchema_[column - 1];
-    }
-
-    public int getPrecision(int column) throws SqlException {
-        checkForClosedStatement();
-        checkForValidColumnIndex(column);
-        int jdbcType = types_[column - 1];
-
-        switch (jdbcType) {
-        case java.sql.Types.NUMERIC:
-        case Types.DECIMAL:
-            return sqlPrecision_[column - 1];
-        case Types.SMALLINT:
-            return 5;
-        case Types.INTEGER:
-            return 10;
-        case Types.BIGINT:
-            return 19;
-        case java.sql.Types.FLOAT:
-            return 15;
-        case Types.REAL:
-            return 7;  // This is the number of signed digits for IEEE float with mantissa 24, ie. 2^24
-        case Types.DOUBLE:
-            return 15; // This is the number of signed digits for IEEE float with mantissa 24, ie. 2^24
-        case Types.CHAR:
-        case Types.VARCHAR:
-        case Types.LONGVARCHAR:
-        case Types.BINARY:
-        case Types.VARBINARY:
-        case Types.LONGVARBINARY:
-        case Types.CLOB:
-        case Types.BLOB:
-            return (int) sqlLength_[column - 1];
-        case Types.DATE:
-            return 10;
-        case Types.TIME:
-            return 8;
-        case Types.TIMESTAMP:
-            return 26;
-        default:
-            throw new SqlException(logWriter_, "Unregistered column type");
-        }
-    }
-
-    public int getScale(int column) throws SqlException {
-        checkForClosedStatement();
-        checkForValidColumnIndex(column);
-
-        // We get the scale from the SQLDA as returned by DERBY, but DERBY does not return the ANSI-defined
-        // value of scale 6 for TIMESTAMP.
-        //
-        //   The JDBC drivers should hardcode this info as a short/near term solution.
-        //
-        if (types_[column - 1] == Types.TIMESTAMP) {
-            return 6;
-        }
-
-        return sqlScale_[column - 1];
-    }
-
-    public String getTableName(int column) throws SqlException {
-        checkForClosedStatement();
-        checkForValidColumnIndex(column);
-        if (sqlxBasename_ == null || sqlxBasename_[column - 1] == null) {
-            return ""; // Per jdbc spec
+    public boolean isSearchable(int column) throws SQLException {
+        try
+        {
+            checkForClosedStatement();
+            checkForValidColumnIndex(column);
+            return true;
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
+        }
+    }
+
+    public boolean isCurrency(int column) throws SQLException {
+        try
+        {
+            checkForClosedStatement();
+            checkForValidColumnIndex(column);
+            return false;
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
+        }
+    }
+
+    public int isNullable(int column) throws SQLException {
+        try
+        {
+            checkForClosedStatement();
+            checkForValidColumnIndex(column);
+            if (nullable_[column - 1]) {
+                return java.sql.ResultSetMetaData.columnNullable;
+            } else {
+                return java.sql.ResultSetMetaData.columnNoNulls;
+            }
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
+        }
+    }
+
+    public boolean isSigned(int column) throws SQLException {
+        try
+        {
+            checkForClosedStatement();
+            checkForValidColumnIndex(column);
+            //return true only if the SQLType is SMALLINT, INT, BIGINT, FLOAT, REAL, DOUBLE, NUMERIC OR DECIMAL
+            int type = types_[column - 1];
+            return
+                    type == Types.SMALLINT ||
+                    type == Types.INTEGER ||
+                    type == Types.BIGINT ||
+                    type == java.sql.Types.FLOAT ||
+                    type == Types.REAL ||
+                    type == Types.DOUBLE ||
+                    type == java.sql.Types.NUMERIC ||
+                    type == Types.DECIMAL;
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
+        }
+}
+
+    public int getColumnDisplaySize(int column) throws SQLException {
+        try
+        {
+            checkForClosedStatement();
+            checkForValidColumnIndex(column);
+            int jdbcType = types_[column - 1];
+            switch (jdbcType) {
+            case Types.BOOLEAN:
+                return 5;
+            case Types.INTEGER:
+                return 11;
+            case Types.SMALLINT:
+                return 6;
+            case Types.BIGINT:
+                return 20;
+            case Types.REAL:
+                return 13;
+            case Types.DOUBLE:
+            case java.sql.Types.FLOAT:
+                return 22;
+            case Types.DECIMAL:
+            case java.sql.Types.NUMERIC:
+                return getPrecision(column) + 2;  // add 1 for sign and 1 for decimal
+            case Types.CHAR:
+            case Types.VARCHAR:
+            case Types.LONGVARCHAR:
+            case Types.CLOB:
+                return (int) sqlLength_[column - 1];
+            case Types.DATE:
+                return 10;
+            case Types.TIME:
+                return 8;
+            case Types.TIMESTAMP:
+                return 26;
+            case Types.BINARY:
+            case Types.VARBINARY:
+            case Types.LONGVARBINARY:
+            case Types.BLOB:
+                return (int) (2 * sqlLength_[column - 1]); // eg. "FF" represents just one byte
+            default:
+                throw new SqlException(logWriter_, "not supported");
+            }
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
+        }
+    }
+
+    public String getColumnLabel(int column) throws SQLException {
+        try
+        {
+            checkForClosedStatement();
+            checkForValidColumnIndex(column);
+            // return labels if label is turned on, otherwise, return column name
+            if (sqlLabel_ != null && sqlLabel_[column - 1] != null) {
+                return sqlLabel_[column - 1];
+            }
+            if (sqlName_ == null || sqlName_[column - 1] == null) {
+                assignColumnName(column);
+            }
+            return sqlName_[column - 1];
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
+        }
+    }
+
+    public String getColumnName(int column) throws SQLException {
+        try
+        {
+            checkForClosedStatement();
+            checkForValidColumnIndex(column);
+            // The Javadoc and Jdbc book explicitly state that the empty string ("") is returned if "not applicable"
+            // for the following methods:
+            //   getSchemaName()
+            //   getTableName()
+            //   getCatalogName()
+            // Since the empty string is a valid string and is not really a proper table name, schema name, or catalog name,
+            // we're not sure why the empty string was chosen over null, except possibly to be friendly to lazy jdbc apps
+            // that may not be checking for nulls, thereby minimizing potential NPE's.
+            // By induction, it would make sense to return the empty string when column name is not available/applicable.
+            //
+            // The JDBC specification contains blanket statements about SQL compliance levels,
+            // so elaboration within the JDBC specification is often bypassed.
+            // Personally, I would prefer to return Java null for all the not-applicable cases,
+            // but it appears that we have precedent for the empty ("") string.
+            //
+            // We assume a straightforward induction from jdbc spec that the column name be "" (empty)
+            // in preference to null or NULL for the not applicable case.
+            //
+            if (sqlName_ == null || sqlName_[column - 1] == null) {
+                assignColumnName(column);
+            }
+            return sqlName_[column - 1];
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
+        }
+    }
+
+    public String getSchemaName(int column) throws SQLException {
+        try
+        {
+            checkForClosedStatement();
+            checkForValidColumnIndex(column);
+            if (sqlxSchema_ == null || sqlxSchema_[column - 1] == null) {
+                return ""; // Per jdbc spec
+            }
+            return sqlxSchema_[column - 1];
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
+        }
+    }
+
+    public int getPrecision(int column) throws SQLException {
+        try
+        {
+            checkForClosedStatement();
+            checkForValidColumnIndex(column);
+            int jdbcType = types_[column - 1];
+
+            switch (jdbcType) {
+            case java.sql.Types.NUMERIC:
+            case Types.DECIMAL:
+                return sqlPrecision_[column - 1];
+            case Types.SMALLINT:
+                return 5;
+            case Types.INTEGER:
+                return 10;
+            case Types.BIGINT:
+                return 19;
+            case java.sql.Types.FLOAT:
+                return 15;
+            case Types.REAL:
+                return 7;  // This is the number of signed digits for IEEE float with mantissa 24, ie. 2^24
+            case Types.DOUBLE:
+                return 15; // This is the number of signed digits for IEEE float with mantissa 24, ie. 2^24
+            case Types.CHAR:
+            case Types.VARCHAR:
+            case Types.LONGVARCHAR:
+            case Types.BINARY:
+            case Types.VARBINARY:
+            case Types.LONGVARBINARY:
+            case Types.CLOB:
+            case Types.BLOB:
+                return (int) sqlLength_[column - 1];
+            case Types.DATE:
+                return 10;
+            case Types.TIME:
+                return 8;
+            case Types.TIMESTAMP:
+                return 26;
+            default:
+                throw new SqlException(logWriter_, "Unregistered column type");
+            }
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
+        }
+    }
+
+    public int getScale(int column) throws SQLException {
+        try
+        {
+            checkForClosedStatement();
+            checkForValidColumnIndex(column);
+
+            // We get the scale from the SQLDA as returned by DERBY, but DERBY does not return the ANSI-defined
+            // value of scale 6 for TIMESTAMP.
+            //
+            //   The JDBC drivers should hardcode this info as a short/near term solution.
+            //
+            if (types_[column - 1] == Types.TIMESTAMP) {
+                return 6;
+            }
+
+            return sqlScale_[column - 1];
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
+        }
+    }
+
+    public String getTableName(int column) throws SQLException {
+        try
+        {
+            checkForClosedStatement();
+            checkForValidColumnIndex(column);
+            if (sqlxBasename_ == null || sqlxBasename_[column - 1] == null) {
+                return ""; // Per jdbc spec
+            }
+            return sqlxBasename_[column - 1];
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
         }
-        return sqlxBasename_[column - 1];
     }
 
     /**
@@ -383,180 +483,229 @@
      *
      * @throws SQLException thrown on failure
      */
-    public String getCatalogName(int column) throws SqlException {
-        checkForClosedStatement();
-        checkForValidColumnIndex(column);
-        return "";
-    }
-
-    public int getColumnType(int column) throws SqlException {
-        checkForClosedStatement();
-        checkForValidColumnIndex(column);
-
-        return types_[column - 1];
-    }
-
-    public String getColumnTypeName(int column) throws SqlException {
-        checkForClosedStatement();
-        checkForValidColumnIndex(column);
-
-        int jdbcType = types_[column - 1];
-        // So these all come back zero for downlevel servers in PROTOCOL.
-        // John is going to write some code to construct the sqlType_ array
-        // based on the protocol types from the query descriptor.
-        int sqlType = sqlType_[column - 1];
-
-        switch (sqlType) {
-        case DRDAConstants.DB2_SQLTYPE_BOOLEAN:
-        case DRDAConstants.DB2_SQLTYPE_NBOOLEAN:
-            return "BOOLEAN";
-        case DRDAConstants.DB2_SQLTYPE_DATE:
-        case DRDAConstants.DB2_SQLTYPE_NDATE:
-            return "DATE";
-        case DRDAConstants.DB2_SQLTYPE_TIME:
-        case DRDAConstants.DB2_SQLTYPE_NTIME:
-            return "TIME";
-        case DRDAConstants.DB2_SQLTYPE_TIMESTAMP:
-        case DRDAConstants.DB2_SQLTYPE_NTIMESTAMP:
-            return "TIMESTAMP";
-        case DRDAConstants.DB2_SQLTYPE_BLOB:
-        case DRDAConstants.DB2_SQLTYPE_NBLOB:
-            return "BLOB";
-        case DRDAConstants.DB2_SQLTYPE_CLOB:
-        case DRDAConstants.DB2_SQLTYPE_NCLOB:
-            return "CLOB";
-        case DRDAConstants.DB2_SQLTYPE_VARCHAR:
-        case DRDAConstants.DB2_SQLTYPE_NVARCHAR:
-            if (jdbcType == Types.VARBINARY) {
-                return "VARCHAR FOR BIT DATA";
-            } else {
-                return "VARCHAR";
+    public String getCatalogName(int column) throws SQLException {
+        try
+        {
+            checkForClosedStatement();
+            checkForValidColumnIndex(column);
+            return "";
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
+        }
+    }
+
+    public int getColumnType(int column) throws SQLException {
+        try
+        {
+            checkForClosedStatement();
+            checkForValidColumnIndex(column);
+
+            return types_[column - 1];
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
+        }
+    }
+
+    public String getColumnTypeName(int column) throws SQLException {
+        try
+        {
+            checkForClosedStatement();
+            checkForValidColumnIndex(column);
+
+            int jdbcType = types_[column - 1];
+            // So these all come back zero for downlevel servers in PROTOCOL.
+            // John is going to write some code to construct the sqlType_ array
+            // based on the protocol types from the query descriptor.
+            int sqlType = sqlType_[column - 1];
+
+            switch (sqlType) {
+            case DRDAConstants.DB2_SQLTYPE_BOOLEAN:
+            case DRDAConstants.DB2_SQLTYPE_NBOOLEAN:
+                return "BOOLEAN";
+            case DRDAConstants.DB2_SQLTYPE_DATE:
+            case DRDAConstants.DB2_SQLTYPE_NDATE:
+                return "DATE";
+            case DRDAConstants.DB2_SQLTYPE_TIME:
+            case DRDAConstants.DB2_SQLTYPE_NTIME:
+                return "TIME";
+            case DRDAConstants.DB2_SQLTYPE_TIMESTAMP:
+            case DRDAConstants.DB2_SQLTYPE_NTIMESTAMP:
+                return "TIMESTAMP";
+            case DRDAConstants.DB2_SQLTYPE_BLOB:
+            case DRDAConstants.DB2_SQLTYPE_NBLOB:
+                return "BLOB";
+            case DRDAConstants.DB2_SQLTYPE_CLOB:
+            case DRDAConstants.DB2_SQLTYPE_NCLOB:
+                return "CLOB";
+            case DRDAConstants.DB2_SQLTYPE_VARCHAR:
+            case DRDAConstants.DB2_SQLTYPE_NVARCHAR:
+                if (jdbcType == Types.VARBINARY) {
+                    return "VARCHAR FOR BIT DATA";
+                } else {
+                    return "VARCHAR";
+                }
+            case DRDAConstants.DB2_SQLTYPE_CHAR:
+            case DRDAConstants.DB2_SQLTYPE_NCHAR:
+                if (jdbcType == Types.BINARY) {
+                    return "CHAR FOR BIT DATA";
+                } else {
+                    return "CHAR";
+                }
+            case DRDAConstants.DB2_SQLTYPE_LONG:
+            case DRDAConstants.DB2_SQLTYPE_NLONG:
+                if (jdbcType == Types.LONGVARBINARY) {
+                    return "LONG VARCHAR FOR BIT DATA";
+                } else {
+                    return "LONG VARCHAR";
+                }
+            case DRDAConstants.DB2_SQLTYPE_CSTR:
+            case DRDAConstants.DB2_SQLTYPE_NCSTR:
+                return "SBCS";
+            case DRDAConstants.DB2_SQLTYPE_FLOAT:
+            case DRDAConstants.DB2_SQLTYPE_NFLOAT:
+                if (jdbcType == Types.DOUBLE) {
+                    return "DOUBLE";
+                }
+                if (jdbcType == Types.REAL) {
+                    return "REAL";
+                }
+            case DRDAConstants.DB2_SQLTYPE_DECIMAL:
+            case DRDAConstants.DB2_SQLTYPE_NDECIMAL:
+                return "DECIMAL";
+            case DRDAConstants.DB2_SQLTYPE_BIGINT:
+            case DRDAConstants.DB2_SQLTYPE_NBIGINT:
+                return "BIGINT";
+            case DRDAConstants.DB2_SQLTYPE_INTEGER:
+            case DRDAConstants.DB2_SQLTYPE_NINTEGER:
+                return "INTEGER";
+            case DRDAConstants.DB2_SQLTYPE_SMALL:
+            case DRDAConstants.DB2_SQLTYPE_NSMALL:
+                return "SMALLINT";
+            case DRDAConstants.DB2_SQLTYPE_NUMERIC:
+            case DRDAConstants.DB2_SQLTYPE_NNUMERIC:
+                return "NUMERIC";
+            default:
+                throw new SqlException(logWriter_, "Not supported");
             }
-        case DRDAConstants.DB2_SQLTYPE_CHAR:
-        case DRDAConstants.DB2_SQLTYPE_NCHAR:
-            if (jdbcType == Types.BINARY) {
-                return "CHAR FOR BIT DATA";
-            } else {
-                return "CHAR";
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
+        }
+    }
+
+    public boolean isReadOnly(int column) throws SQLException {
+        try
+        {
+            checkForClosedStatement();
+            checkForValidColumnIndex(column);
+            if (sqlxUpdatable_ == null) {
+                return (resultSetConcurrency_ == java.sql.ResultSet.CONCUR_READ_ONLY); // If no extended describe, return resultSet's concurrecnty
             }
-        case DRDAConstants.DB2_SQLTYPE_LONG:
-        case DRDAConstants.DB2_SQLTYPE_NLONG:
-            if (jdbcType == Types.LONGVARBINARY) {
-                return "LONG VARCHAR FOR BIT DATA";
-            } else {
-                return "LONG VARCHAR";
+            return sqlxUpdatable_[column - 1] == 0; // PROTOCOL 0 means not updatable, 1 means updatable
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
+        }
+    }
+
+    public boolean isWritable(int column) throws SQLException {
+        try
+        {
+            checkForClosedStatement();
+            checkForValidColumnIndex(column);
+            if (sqlxUpdatable_ == null) {
+                return (resultSetConcurrency_ == java.sql.ResultSet.CONCUR_UPDATABLE); // If no extended describe, return resultSet's concurrency
             }
-        case DRDAConstants.DB2_SQLTYPE_CSTR:
-        case DRDAConstants.DB2_SQLTYPE_NCSTR:
-            return "SBCS";
-        case DRDAConstants.DB2_SQLTYPE_FLOAT:
-        case DRDAConstants.DB2_SQLTYPE_NFLOAT:
-            if (jdbcType == Types.DOUBLE) {
-                return "DOUBLE";
-            }
-            if (jdbcType == Types.REAL) {
-                return "REAL";
-            }
-        case DRDAConstants.DB2_SQLTYPE_DECIMAL:
-        case DRDAConstants.DB2_SQLTYPE_NDECIMAL:
-            return "DECIMAL";
-        case DRDAConstants.DB2_SQLTYPE_BIGINT:
-        case DRDAConstants.DB2_SQLTYPE_NBIGINT:
-            return "BIGINT";
-        case DRDAConstants.DB2_SQLTYPE_INTEGER:
-        case DRDAConstants.DB2_SQLTYPE_NINTEGER:
-            return "INTEGER";
-        case DRDAConstants.DB2_SQLTYPE_SMALL:
-        case DRDAConstants.DB2_SQLTYPE_NSMALL:
-            return "SMALLINT";
-        case DRDAConstants.DB2_SQLTYPE_NUMERIC:
-        case DRDAConstants.DB2_SQLTYPE_NNUMERIC:
-            return "NUMERIC";
-        default:
-            throw new SqlException(logWriter_, "Not supported");
+            return sqlxUpdatable_[column - 1] == 1; // PROTOCOL 0 means not updatable, 1 means updatable
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
         }
     }
 
-    public boolean isReadOnly(int column) throws SqlException {
-        checkForClosedStatement();
-        checkForValidColumnIndex(column);
-        if (sqlxUpdatable_ == null) {
-            return (resultSetConcurrency_ == java.sql.ResultSet.CONCUR_READ_ONLY); // If no extended describe, return resultSet's concurrecnty
-        }
-        return sqlxUpdatable_[column - 1] == 0; // PROTOCOL 0 means not updatable, 1 means updatable
-    }
-
-    public boolean isWritable(int column) throws SqlException {
-        checkForClosedStatement();
-        checkForValidColumnIndex(column);
-        if (sqlxUpdatable_ == null) {
-            return (resultSetConcurrency_ == java.sql.ResultSet.CONCUR_UPDATABLE); // If no extended describe, return resultSet's concurrency
-        }
-        return sqlxUpdatable_[column - 1] == 1; // PROTOCOL 0 means not updatable, 1 means updatable
-    }
-
-    public boolean isDefinitelyWritable(int column) throws SqlException {
-        checkForClosedStatement();
-        checkForValidColumnIndex(column);
-        if (sqlxUpdatable_ == null) {
-            return false;
+    public boolean isDefinitelyWritable(int column) throws SQLException {
+        try
+        {
+            checkForClosedStatement();
+            checkForValidColumnIndex(column);
+            if (sqlxUpdatable_ == null) {
+                return false;
+            }
+            return sqlxUpdatable_[column - 1] == 1; // PROTOCOL 0 means not updatable, 1 means updatable
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
         }
-        return sqlxUpdatable_[column - 1] == 1; // PROTOCOL 0 means not updatable, 1 means updatable
     }
 
     //--------------------------jdbc 2.0-----------------------------------
 
-    public String getColumnClassName(int column) throws SqlException {
-        checkForClosedStatement();
-        checkForValidColumnIndex(column);
-
-        int jdbcType = types_[column - 1];
-        switch (jdbcType) {
-        case java.sql.Types.BIT:
-            return "java.lang.Boolean";
-        case java.sql.Types.TINYINT:
-            return "java.lang.Integer";
-        case Types.SMALLINT:
-            return "java.lang.Integer";
-        case Types.INTEGER:
-            return "java.lang.Integer";
-        case Types.BIGINT:
-            return "java.lang.Long";
-        case java.sql.Types.FLOAT:
-            return "java.lang.Double";
-        case Types.REAL:
-            return "java.lang.Float";
-        case Types.DOUBLE:
-            return "java.lang.Double";
-        case java.sql.Types.NUMERIC:
-        case Types.DECIMAL:
-            return "java.math.BigDecimal";
-        case Types.CHAR:
-        case Types.VARCHAR:
-        case Types.LONGVARCHAR:
-            return "java.lang.String";
-        case Types.DATE:
-            return "java.sql.Date";
-        case Types.TIME:
-            return "java.sql.Time";
-        case Types.TIMESTAMP:
-            return "java.sql.Timestamp";
-        case Types.BINARY:
-        case Types.VARBINARY:
-        case Types.LONGVARBINARY:
-            return "byte[]";
-        case java.sql.Types.STRUCT:
-            return "java.sql.Struct";
-        case java.sql.Types.ARRAY:
-            return "java.sql.Array";
-        case Types.BLOB:
-            return "java.sql.Blob";
-        case Types.CLOB:
-            return "java.sql.Clob";
-        case java.sql.Types.REF:
-            return "java.sql.Ref";
-        default:
-            throw new SqlException(logWriter_, "Not supported");
+    public String getColumnClassName(int column) throws SQLException {
+        try
+        {
+            checkForClosedStatement();
+            checkForValidColumnIndex(column);
+
+            int jdbcType = types_[column - 1];
+            switch (jdbcType) {
+            case java.sql.Types.BIT:
+                return "java.lang.Boolean";
+            case java.sql.Types.TINYINT:
+                return "java.lang.Integer";
+            case Types.SMALLINT:
+                return "java.lang.Integer";
+            case Types.INTEGER:
+                return "java.lang.Integer";
+            case Types.BIGINT:
+                return "java.lang.Long";
+            case java.sql.Types.FLOAT:
+                return "java.lang.Double";
+            case Types.REAL:
+                return "java.lang.Float";
+            case Types.DOUBLE:
+                return "java.lang.Double";
+            case java.sql.Types.NUMERIC:
+            case Types.DECIMAL:
+                return "java.math.BigDecimal";
+            case Types.CHAR:
+            case Types.VARCHAR:
+            case Types.LONGVARCHAR:
+                return "java.lang.String";
+            case Types.DATE:
+                return "java.sql.Date";
+            case Types.TIME:
+                return "java.sql.Time";
+            case Types.TIMESTAMP:
+                return "java.sql.Timestamp";
+            case Types.BINARY:
+            case Types.VARBINARY:
+            case Types.LONGVARBINARY:
+                return "byte[]";
+            case java.sql.Types.STRUCT:
+                return "java.sql.Struct";
+            case java.sql.Types.ARRAY:
+                return "java.sql.Array";
+            case Types.BLOB:
+                return "java.sql.Blob";
+            case Types.CLOB:
+                return "java.sql.Clob";
+            case java.sql.Types.REF:
+                return "java.sql.Ref";
+            default:
+                throw new SqlException(logWriter_, "Not supported");
+            }
+        }
+        catch ( SqlException e )
+        {
+            throw e.getSQLException();
         }
     }
 



Mime
View raw message