db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davi...@apache.org
Subject svn commit: r391139 - in /db/derby/code/trunk: java/build/org/apache/derbyBuild/ java/client/org/apache/derby/client/am/ java/client/org/apache/derby/loc/ java/shared/org/apache/derby/shared/common/reference/ java/testing/org/apache/derbyTesting/functi...
Date Mon, 03 Apr 2006 20:19:59 GMT
Author: davidvc
Date: Mon Apr  3 13:19:57 2006
New Revision: 391139

URL: http://svn.apache.org/viewcvs?rev=391139&view=rev
Log:
DERBY-842 : (Partial) - internationalized ColumnMetaData.java and also
removed some methods that were not in use.  Passes derbynetclientmats.


Modified:
    db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/ColumnMetaData.java
    db/derby/code/trunk/java/client/org/apache/derby/loc/clientmessages_en.properties
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/parameterMetaDataJdbc30.out
    db/derby/code/trunk/tools/testing/i18nTestGenerator/genClient2.sed

Modified: db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java?rev=391139&r1=391138&r2=391139&view=diff
==============================================================================
--- db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java (original)
+++ db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java Mon Apr  3 13:19:57
2006
@@ -61,6 +61,9 @@
         clientMessageIds.add(SQLState.LANG_DATE_SYNTAX_EXCEPTION);
         clientMessageIds.add(SQLState.CHARACTER_CONVERTER_NOT_AVAILABLE);
         clientMessageIds.add(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE);
+        clientMessageIds.add(SQLState.LANG_STATEMENT_CLOSED_NO_REASON);
+        clientMessageIds.add(SQLState.LANG_INVALID_COLUMN_POSITION);
+        clientMessageIds.add(SQLState.INVALID_COLUMN_NAME);
     }
 
 	public static void main(String[] args) throws Exception {

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=391139&r1=391138&r2=391139&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 Apr
 3 13:19:57 2006
@@ -24,6 +24,7 @@
 
 import org.apache.derby.iapi.reference.DRDAConstants;
 import org.apache.derby.iapi.reference.JDBC30Translation;
+import org.apache.derby.shared.common.reference.SQLState;
 
 // Under JDBC 2, we must new up our parameter meta data as column meta data instances
 // Once we move to JDK 1.4 pre-req, create a ResultSetMetaData class and make this class
abstract
@@ -106,7 +107,8 @@
     void checkForClosedStatement() throws SqlException {
         // agent_.checkForDeferredExceptions();
         if (statementClosed_) {
-            throw new SqlException(logWriter_, "Statement closed");
+            throw new SqlException(logWriter_, 
+            		new MessageId (SQLState.LANG_STATEMENT_CLOSED_NO_REASON));
         }
     }
 
@@ -308,7 +310,8 @@
             case Types.BLOB:
                 return (int) (2 * sqlLength_[column - 1]); // eg. "FF" represents just one
byte
             default:
-                throw new SqlException(logWriter_, "not supported");
+                throw new SqlException(logWriter_, 
+                		new MessageId (SQLState.UNSUPPORTED_TYPE));
             }
         }
         catch ( SqlException e )
@@ -426,7 +429,8 @@
             case Types.TIMESTAMP:
                 return 26;
             default:
-                throw new SqlException(logWriter_, "Unregistered column type");
+                throw new SqlException(logWriter_, 
+                		new MessageId (SQLState.UNSUPPORTED_TYPE));
             }
         }
         catch ( SqlException e )
@@ -589,7 +593,8 @@
             case DRDAConstants.DB2_SQLTYPE_NNUMERIC:
                 return "NUMERIC";
             default:
-                throw new SqlException(logWriter_, "Not supported");
+                throw new SqlException(logWriter_, 
+                		new MessageId (SQLState.UNSUPPORTED_TYPE));
             }
         }
         catch ( SqlException e )
@@ -700,7 +705,8 @@
             case java.sql.Types.REF:
                 return "java.sql.Ref";
             default:
-                throw new SqlException(logWriter_, "Not supported");
+                throw new SqlException(logWriter_, 
+                		new MessageId (SQLState.UNSUPPORTED_TYPE));
             }
         }
         catch ( SqlException e )
@@ -714,8 +720,9 @@
 
     void checkForValidColumnIndex(int column) throws SqlException {
         if (column < 1 || column > columns_) {
-            throw new SqlException(logWriter_, "Invalid argument: column index " +
-                    column + " is out of range.");
+            throw new SqlException(logWriter_, 
+            		new MessageId (SQLState.LANG_INVALID_COLUMN_POSITION),
+            		new Integer (column), new Integer(columns_));
         }
     }
 
@@ -734,11 +741,13 @@
         return sqlxParmmode_[parameterIndex - 1] >= java.sql.ParameterMetaData.parameterModeInOut;
     }
 
+    /** This method does not appear to be in use -- davidvc@apache.org
     // Only called when column meta data is not described. Called by setXXX methods.
     public void guessInputParameterMetaData(int parameterIndex,
                                             int jdbcType) throws SqlException {
         guessInputParameterMetaData(parameterIndex, jdbcType, 0);
     }
+     */
 
     private void setParmModeForInputParameter(int parameterIndex) {
         if (sqlxParmmode_[parameterIndex - 1] == java.sql.ParameterMetaData.parameterModeOut)
{
@@ -748,24 +757,6 @@
         }
     }
 
-    // Only called when column meta data is not described. Called by setXXX methods.
-    // Scale is only applied for Decimal or Numeric JDBC type.
-    public void guessInputParameterMetaData(int parameterIndex,
-                                            int jdbcType,
-                                            int scale) throws SqlException {
-        setParmModeForInputParameter(parameterIndex);
-        int driverType = getInternalTypeForGuessedOrRegisteredJdbcType(jdbcType);
-        // if output parameter has been registered already
-        if (isParameterModeGuessedAsOutput(parameterIndex)) {
-            if (!isCompatibleDriverTypes(types_[parameterIndex - 1], driverType)) {
-                throw new SqlException(logWriter_, "The jdbcType " + jdbcType + " does not
match between the setter method and " +
-                        "the registerOutParameter method.");
-            } else {
-                return; // don't bother guessing if the parameter was already registered
-            }
-        }
-        guessParameterMetaDataBasedOnSupportedDriverType(parameterIndex, jdbcType == java.sql.Types.BIGINT,
driverType, scale);
-    }
 
     private void setParmModeForOutputParameter(int parameterIndex) {
         if (sqlxParmmode_[parameterIndex - 1] == java.sql.ParameterMetaData.parameterModeIn)
{
@@ -775,23 +766,6 @@
         }
     }
 
-    // Only called when column meta data is not described, called by registerOutParameter
methods.
-    public void guessOutputParameterMetaData(int parameterIndex,
-                                             int jdbcType,
-                                             int scale) throws SqlException {
-        setParmModeForOutputParameter(parameterIndex);
-        int driverType = getInternalTypeForGuessedOrRegisteredJdbcType(jdbcType);
-        if (isParameterModeGuessedAsAnInput(parameterIndex)) { // if input parameter has
been set already
-            // Verify that "set" and "registered" types are compatible.
-            if (!isCompatibleDriverTypes(driverType, types_[parameterIndex - 1])) {
-                throw new SqlException(logWriter_, "The jdbcType does not match between the
setter method and " +
-                        "the registerOutParameter method.");
-            }
-            // the registered type will take precedence over any previously guessed input
"set" type
-        }
-        guessParameterMetaDataBasedOnSupportedDriverType(parameterIndex, jdbcType == java.sql.Types.BIGINT,
driverType, scale);
-    }
-
     private boolean isCompatibleDriverTypes(int registeredType, int guessedInputType) {
         switch (registeredType) {
         case Types.CHAR:
@@ -850,153 +824,14 @@
             return Types.CLOB;
         case java.sql.Types.NULL:
         case java.sql.Types.OTHER:
-            throw new SqlException(logWriter_, "Jdbc type " + guessedOrRegisteredJdbcType
+ " not yet supported.");
-        default:
-            throw new SqlException(logWriter_, "Unrecognized jdbc type " + guessedOrRegisteredJdbcType);
-        }
-    }
-
-    private void guessParameterMetaDataBasedOnSupportedDriverType(int parameterIndex,
-                                                                  boolean isBigInt,
-                                                                  int driverType,
-                                                                  int scale) throws SqlException
{
-        switch (driverType) {
-        case Types.SMALLINT:
-            guessParameterMetaData(parameterIndex, driverType, 2, 0, 0);
-            break;
-        case Types.INTEGER:
-            guessParameterMetaData(parameterIndex, driverType, 4, 0, 0);
-            break;
-        case Types.BIGINT:
-            guessParameterMetaData(parameterIndex, driverType, 8, 0, 0);
-            break;
-        case Types.REAL:
-            guessParameterMetaData(parameterIndex, driverType, 4, 0, 0);
-            break;
-        case Types.DOUBLE:
-            guessParameterMetaData(parameterIndex, driverType, 8, 0, 0);
-            break;
-        case Types.DECIMAL:
-            if (isBigInt) {
-                guessParameterMetaData(parameterIndex, driverType, 0, 19, 0);
-            } else {
-                guessParameterMetaData(parameterIndex, driverType, 0, 31, scale);
-            }
-            break;
-        case Types.DATE:
-            guessParameterMetaData(parameterIndex, driverType, 10, 0, 0);
-            break;
-        case Types.TIME:
-            guessParameterMetaData(parameterIndex, driverType, 8, 0, 0);
-            break;
-        case Types.TIMESTAMP:
-            guessParameterMetaData(parameterIndex, driverType, 26, 0, 0);
-            break;
-        case Types.CHAR:
-        case Types.VARCHAR:
-            guessParameterMetaData(parameterIndex, driverType, 32672, 0, 0);
-            break;
-        case Types.LONGVARCHAR:
-            guessParameterMetaData(parameterIndex, driverType, 32700, 0, 0);
-            break;
-        case Types.BINARY:
-        case Types.VARBINARY:
-            guessParameterMetaData(parameterIndex, driverType, 4000, 0, 0);
-            break;
-        case Types.LONGVARBINARY:
-            guessParameterMetaData(parameterIndex, driverType, 32700, 0, 0);
-            break;
-        case Types.BLOB:
-            // 32768 will cause 8004 for a null placeholder length (could hard code in NET
layer)
-            guessParameterMetaData(parameterIndex, driverType, 32768, 0, 0);
-            break;
-        case Types.CLOB:
-            // 32768 will cause 8004 for a null placeholder length (could hard code in NET
layer)
-            guessParameterMetaData(parameterIndex, driverType, 32768, 0, 0);
-            break;
-        default:
-            throw new SqlException(logWriter_, "Unrecognized driver type " + driverType);
-        }
-    }
-
-    // Only called when column meta data is not described
-    private void guessParameterMetaData(int parameterIndex,
-                                        int type,
-                                        int length,
-                                        int precision,
-                                        int scale) {
-        // Always guess that the column is nullable
-        nullable_[parameterIndex - 1] = true;
-        types_[parameterIndex - 1] = type;
-        sqlLength_[parameterIndex - 1] = length;
-        sqlPrecision_[parameterIndex - 1] = precision;
-        sqlScale_[parameterIndex - 1] = scale;
-        sqlType_[parameterIndex - 1] = mapDriverToSqlType(type, true);
-    }
-
-    int mapDriverToSqlType(int type, boolean nullable) {
-        int sqlType = 0;
-        switch (type) {
-        case JDBC30Translation.BOOLEAN:
-            sqlType = DRDAConstants.DB2_SQLTYPE_NBOOLEAN;
-            break;
-        case java.sql.Types.SMALLINT:
-            sqlType = DRDAConstants.DB2_SQLTYPE_NSMALL;
-            break;
-        case java.sql.Types.INTEGER:
-            sqlType = DRDAConstants.DB2_SQLTYPE_NINTEGER;
-            break;
-        case java.sql.Types.BIGINT:
-            sqlType = DRDAConstants.DB2_SQLTYPE_NBIGINT;
-            break;
-        case java.sql.Types.REAL:
-        case java.sql.Types.DOUBLE:
-        case java.sql.Types.FLOAT:
-            sqlType = DRDAConstants.DB2_SQLTYPE_NFLOAT;
-            break;
-        case java.sql.Types.DATE:
-            sqlType = DRDAConstants.DB2_SQLTYPE_NDATE;
-            break;
-        case java.sql.Types.TIME:
-            sqlType = DRDAConstants.DB2_SQLTYPE_NTIME;
-            break;
-        case java.sql.Types.TIMESTAMP:
-            sqlType = DRDAConstants.DB2_SQLTYPE_NTIMESTAMP;
-            break;
-        case java.sql.Types.CHAR:
-        case java.sql.Types.VARCHAR:
-            sqlType = DRDAConstants.DB2_SQLTYPE_NVARCHAR;
-            break;
-        case java.sql.Types.LONGVARCHAR:
-            sqlType = DRDAConstants.DB2_SQLTYPE_NLONG;
-            break;
-        case java.sql.Types.BINARY:
-        case java.sql.Types.VARBINARY:
-            sqlType = DRDAConstants.DB2_SQLTYPE_NVARCHAR;
-            break;
-        case java.sql.Types.LONGVARBINARY:
-            sqlType = DRDAConstants.DB2_SQLTYPE_NLONG;
-            break;
-        case java.sql.Types.NUMERIC:
-        case java.sql.Types.DECIMAL:
-            sqlType = DRDAConstants.DB2_SQLTYPE_NDECIMAL;
-            break;
-        case java.sql.Types.BLOB:
-            sqlType = DRDAConstants.DB2_SQLTYPE_NBLOB;
-            break;
-        case java.sql.Types.CLOB:
-            sqlType = DRDAConstants.DB2_SQLTYPE_NCLOB;
-            break;
+            throw new SqlException(logWriter_, 
+            		new MessageId (SQLState.UNSUPPORTED_TYPE));
         default:
-            break; // bug check
-        }
-        if (!nullable) {
-            sqlType--;
+            throw new SqlException(logWriter_, 
+            		new MessageId (SQLState.UNSUPPORTED_TYPE));
         }
-        return sqlType;
     }
 
-
     public void setLogWriter(LogWriter logWriter) {
         logWriter_ = logWriter;
     }
@@ -1065,7 +900,8 @@
                 return col + 1;
             }
         }
-        throw new SqlException(logWriter_, "Invalid argument: unknown column name " + columnName);
+        throw new SqlException(logWriter_, 
+        		new MessageId (SQLState.INVALID_COLUMN_NAME), columnName);
     }
 
     // assign ordinal position as the column name if null.

Modified: db/derby/code/trunk/java/client/org/apache/derby/loc/clientmessages_en.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/loc/clientmessages_en.properties?rev=391139&r1=391138&r2=391139&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/loc/clientmessages_en.properties (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/loc/clientmessages_en.properties Mon
Apr  3 13:19:57 2006
@@ -70,11 +70,7 @@
 XN056.S=Clob object is too large
 XN057.S=Invalid position {0}
 XN058.S=Invalid offset {0}
-XN059.S=Unsupported Type
-XN060.S=Unregistered column type
-XN061.S=The jdbcType {0} does not match between the setter method and the registerOutParameter
method.
-XN062.S=Unrecognized jdbc type {0}
-XN063.S=Unrecognized driver type {0}
+XN059.S=Unsupported type.
 XN064.S=An attempt to execute a privileged action failed.
 XN065.S=A resource bundle could not be found in the {0} package for {1}
 XN067.S=Cannot rollback or release a savepoint that was not created by this connection.

Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java?rev=391139&r1=391138&r2=391139&view=diff
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
(original)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
Mon Apr  3 13:19:57 2006
@@ -1558,10 +1558,6 @@
     String INVALID_POSITION                                         = "XN057.S";
     String INVALID_OFFSET                                           = "XN058.S";
     String UNSUPPORTED_TYPE                                         = "XN059.S";
-    String UNREGISTERED_COLUMN_TYPE                                 = "XN060.S";
-    String TYPE_MISMATH_WITH_REG_TYPE                               = "XN061.S";
-    String BAD_JDBC_TYPE                                            = "XN062.S";
-    String BAD_DRIVER_TYPE                                          = "XN063.S";
     String ERROR_PRIVILEGED_ACTION                                  = "XN064.S";
     String MISSING_RESOURCE_BUNDLE                                  = "XN065.S";
     String SAVEPOINT_NOT_CREATED_BY_CONNECTION                      = "XN067.S";

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/parameterMetaDataJdbc30.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/parameterMetaDataJdbc30.out?rev=391139&r1=391138&r2=391139&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/parameterMetaDataJdbc30.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/parameterMetaDataJdbc30.out
Mon Apr  3 13:19:57 2006
@@ -155,11 +155,11 @@
 parameter getParameterClassName java.lang.Integer
 parameter getParameterMode PARAMETER_MODE_IN
 PASS -- expected exception
-SQLSTATE(null): SQL Exception: Invalid argument: column index -1 is out of range.
+SQLSTATE(XCL14): SQL Exception: The column position '-1' is out of range.  The number of
columns for this ResultSet is '1'.
 PASS -- expected exception
-SQLSTATE(null): SQL Exception: Invalid argument: column index 0 is out of range.
+SQLSTATE(XCL14): SQL Exception: The column position '0' is out of range.  The number of columns
for this ResultSet is '1'.
 PASS -- expected exception
-SQLSTATE(null): SQL Exception: Invalid argument: column index 2 is out of range.
+SQLSTATE(XCL14): SQL Exception: The column position '2' is out of range.  The number of columns
for this ResultSet is '1'.
 test: no parameter for the statement and then do getParameterMetaData()
 parameters count for prepared statement is 0
 test: the scale returned should be the one set by registerOutParameter

Modified: db/derby/code/trunk/tools/testing/i18nTestGenerator/genClient2.sed
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/tools/testing/i18nTestGenerator/genClient2.sed?rev=391139&r1=391138&r2=391139&view=diff
==============================================================================
--- db/derby/code/trunk/tools/testing/i18nTestGenerator/genClient2.sed (original)
+++ db/derby/code/trunk/tools/testing/i18nTestGenerator/genClient2.sed Mon Apr  3 13:19:57
2006
@@ -40,6 +40,7 @@
 s/e.getClass().getName()/"exceptionClassName"/g
 s/[[:space:]]sourceType/"sourceType"/g
 s/[[:space:]]targetType/ "targetType"/g
+s/[[:space:]]columnName/ "columnName"/g
 
 #
 # Subsitute Long and Integer params with 0 as a default



Mime
View raw message