You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by da...@apache.org on 2006/04/20 06:59:34 UTC

svn commit: r395484 [1/2] - in /db/derby/code/trunk: java/build/org/apache/derbyBuild/ java/client/org/apache/derby/client/am/ java/client/org/apache/derby/client/net/ java/engine/org/apache/derby/loc/ java/shared/org/apache/derby/shared/common/referen...

Author: davidvc
Date: Wed Apr 19 21:59:30 2006
New Revision: 395484

URL: http://svn.apache.org/viewcvs?rev=395484&view=rev
Log:
DERBY-843: Internationalize SectionManager to XaException in client/am
package.  Also cleaned up any remaining hardcoded text in this package.
Also fixed DERBY-1198, where jdbc4/StatementTest.java was using
SQLState directly.

Passes derbynetclientmats on jdk14 and jdbc40 on jdk16, and fixed output 
files for jdk13 and jdk16 for those tests whose output files were 
affected in the derbynetclientmats run.


Removed:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/ConversionException.java
Modified:
    db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Agent.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/DatabaseMetaData.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/DateTime.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Decimal.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/DisconnectException.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/SectionManager.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlCode.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlException.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Utils.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Version.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/Request.java
    db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_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/autoGeneratedJdbc30.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/forupdate.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/holdCursorIJ.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/procedure.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/updatableResultSet.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk16/parameterMapping.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk16/procedure.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk16/updatableResultSet.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/parameterMapping.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/procedure.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/scrollCursors2.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/updatableResultSet.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTest.java
    db/derby/code/trunk/tools/testing/i18nTestGenerator/clientPrologue.txt
    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=395484&r1=395483&r2=395484&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 Wed Apr 19 21:59:30 2006
@@ -67,7 +67,6 @@
         clientMessageIds.add(SQLState.LANG_STATEMENT_CLOSED_NO_REASON);
         clientMessageIds.add(SQLState.LANG_INVALID_COLUMN_POSITION);
         clientMessageIds.add(SQLState.INVALID_COLUMN_NAME);
-        clientMessageIds.add("J104");
         clientMessageIds.add(SQLState.HOLDABLE_RESULT_SET_NOT_AVAILABLE);
         clientMessageIds.add(SQLState.LANG_RETURN_OUTPUT_PARAM_CANNOT_BE_SET);
         clientMessageIds.add(SQLState.LANG_NULL_INTO_NON_NULL);
@@ -84,10 +83,21 @@
         clientMessageIds.add(SQLState.NUMBER_OF_ROWS_TOO_LARGE_FOR_INT);
         clientMessageIds.add(SQLState.NOGETCONN_ON_CLOSED_POOLED_CONNECTION);
         clientMessageIds.add(SQLState.LOB_METHOD_ON_CLOSED_CONNECTION);
+        clientMessageIds.add(SQLState.LANG_INVALID_CALL_TO_EXECUTE_UPDATE);
+        clientMessageIds.add(SQLState.LANG_CANT_INVALIDATE_OPEN_RESULT_SET);
+        clientMessageIds.add(SQLState.YEAR_EXCEEDS_MAXIMUM);
         clientMessageIds.add(SQLState.LANG_INVALID_PARAM_POSITION);
         clientMessageIds.add(SQLState.LANG_MISSING_PARMS);
         clientMessageIds.add(SQLState.LANG_NO_CURRENT_ROW);
         clientMessageIds.add(SQLState.LANG_STREAM_RETRIEVED_ALREADY);
+        clientMessageIds.add(SQLState.CONNECTION_FAILED_ON_RESET);
+        clientMessageIds.add(SQLState.DECIMAL_TOO_MANY_DIGITS);
+        clientMessageIds.add(SQLState.NUMERIC_OVERFLOW);
+        clientMessageIds.add(SQLState.UNSUPPORTED_HOLDABILITY_PROPERTY);
+        clientMessageIds.add(SQLState.CANCEL_NOT_SUPPORTED_BY_SERVER);
+        clientMessageIds.add(SQLState.LANG_INVALID_CALL_STATEMENT);
+        clientMessageIds.add(SQLState.LOSS_OF_PRECISION_EXCEPTION);
+        clientMessageIds.add(SQLState.LANG_INVALID_SQL_IN_BATCH);
         clientMessageIds.add(SQLState.CLIENT_RESULT_SET_NOT_OPEN);
     }
 
@@ -191,9 +201,9 @@
     /**
      * Determine if this is a message that the client is using
      *
-     * We assume all message ids starting with "XJ" are client messages
+     * We assume all message ids starting with "XJ" or "J" are client messages
      * (even though many of them may not be, it saves the coder the effort
-     * of explicitly adding each XJ shared message, and covers 90% of the
+     * of explicitly adding each XJ or J shared message, and covers 90% of the
      * shared messages
      *
      * All other shared message ids should be added to the static array
@@ -201,7 +211,7 @@
      */
     static boolean isClientMessage(String messageId)
     {
-        if ( messageId.startsWith("XJ") )
+        if ( messageId.startsWith("XJ") || messageId.startsWith("J") )
         {
             return true;
         }

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Agent.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/Agent.java?rev=395484&r1=395483&r2=395484&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Agent.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Agent.java Wed Apr 19 21:59:30 2006
@@ -20,6 +20,8 @@
 
 package org.apache.derby.client.am;
 
+import org.apache.derby.shared.common.reference.SQLState;
+
 public abstract class Agent {
     public SqlException accumulatedReadExceptions_ = null;
 
@@ -264,12 +266,9 @@
             }
         }
         if (accumulatedExceptions != null) {
-            BatchUpdateException bue =
-                    new BatchUpdateException(logWriter_,
-                            "Non-atomic batch failure.  The batch was submitted, but " +
-                    "at least one exception occurred on an individual member of the batch. " +
-                    "Use getNextException() to retrieve the exceptions for specific batched elements.",
-                            updateCounts);
+            BatchUpdateException bue = new BatchUpdateException(logWriter_,
+                new MessageId(SQLState.BATCH_NON_ATOMIC_FAILURE),
+                updateCounts);
             bue.setNextException(accumulatedExceptions.getSQLException());
             throw bue;
         }

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java?rev=395484&r1=395483&r2=395484&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java Wed Apr 19 21:59:30 2006
@@ -1835,7 +1835,8 @@
         try {
             reset_(logWriter, user, password, ds, recomputeFromDataSource);
         } catch (SqlException sqle) {
-            DisconnectException de = new DisconnectException(agent_, "An error occurred during connect reset and the connection has been terminated.  See chained exceptions for details.");
+            DisconnectException de = new DisconnectException(agent_, 
+                new MessageId(SQLState.CONNECTION_FAILED_ON_RESET));
             de.setNextException(sqle);
             throw de;
         }
@@ -1848,7 +1849,8 @@
         try {
             reset_(logWriter, ds, recomputeFromDataSource);
         } catch (SqlException sqle) {
-            DisconnectException de = new DisconnectException(agent_, "An error occurred during connect reset and the connection has been terminated.  See chained exceptions for details.");
+            DisconnectException de = new DisconnectException(agent_, 
+                new MessageId(SQLState.CONNECTION_FAILED_ON_RESET));
             de.setNextException(sqle);
             throw de;
         }

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/DatabaseMetaData.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/DatabaseMetaData.java?rev=395484&r1=395483&r2=395484&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/DatabaseMetaData.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/DatabaseMetaData.java Wed Apr 19 21:59:30 2006
@@ -2071,12 +2071,12 @@
         } catch (SqlException e) {
             if (e.getErrorCode() == -440) {
                 SqlException newException = new SqlException(agent_.logWriter_,
-                        "The required stored procedure is not installed on the server.");
+                        new MessageId(SQLState.STORED_PROC_NOT_INSTALLED));
                 newException.setNextException(e);
                 throw newException;
             } else if (e.getErrorCode() == -444) {
                 SqlException newException = new SqlException(agent_.logWriter_,
-                        "The load module name for the stored procedure on the server is not found. ");
+                    new MessageId(SQLState.STORED_PROC_LOAD_MODULE_NOT_FOUND));
                 newException.setNextException(e);
                 throw newException;
             } else {
@@ -2556,9 +2556,8 @@
         if (serverJdbcMajorVersion < major ||
             (serverJdbcMajorVersion == major &&
              serverJdbcMinorVersion < minor)) {
-            MessageId mid =
-                new MessageId(SQLState.JDBC_METHOD_NOT_SUPPORTED_BY_SERVER);
-            throw new SqlException(agent_.logWriter_, mid, method);
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.JDBC_METHOD_NOT_SUPPORTED_BY_SERVER), method);
         }
     }
 }

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/DateTime.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/DateTime.java?rev=395484&r1=395483&r2=395484&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/DateTime.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/DateTime.java Wed Apr 19 21:59:30 2006
@@ -19,6 +19,9 @@
 */
 package org.apache.derby.client.am;
 
+import org.apache.derby.shared.common.i18n.MessageUtil;
+import org.apache.derby.shared.common.reference.SQLState;
+
 import java.io.UnsupportedEncodingException;
 
 
@@ -72,7 +75,10 @@
             monthIndx = 5;
             dayIndx = 8;
         } else {
-            throw new java.lang.IllegalArgumentException("Unsupported date format!");
+            throw new java.lang.IllegalArgumentException(
+                MessageUtil.getCompleteMessage(SQLState.LANG_FORMAT_EXCEPTION,
+                    SqlException.CLIENT_MESSAGE_RESOURCE_NAME,
+                    (Object[])null));
         }
 
         int zeroBase = ((int) '0');
@@ -224,10 +230,12 @@
      */
     public static final int dateToDateBytes(byte[] buffer,
                                             int offset,
-                                            java.sql.Date date) throws ConversionException {
+                                            java.sql.Date date) throws SqlException {
         int year = date.getYear() + 1900;
         if (year > 9999) {
-            throw new ConversionException("Year exceeds the maximum \"9999\".");
+            throw new SqlException(null,
+                new MessageId(SQLState.YEAR_EXCEEDS_MAXIMUM),
+                new Integer(year), "9999");
         }
         int month = date.getMonth() + 1;
         int day = date.getDate();
@@ -283,10 +291,12 @@
      */
     public static final int timestampToTimestampBytes(byte[] buffer,
                                                       int offset,
-                                                      java.sql.Timestamp timestamp) throws ConversionException {
+                                                      java.sql.Timestamp timestamp) throws SqlException {
         int year = timestamp.getYear() + 1900;
         if (year > 9999) {
-            throw new ConversionException("Year exceeds the maximum \"9999\".");
+            throw new SqlException(null,
+                new MessageId(SQLState.YEAR_EXCEEDS_MAXIMUM),
+                new Integer(year), "9999");
         }
         int month = timestamp.getMonth() + 1;
         int day = timestamp.getDate();
@@ -544,10 +554,12 @@
      */
     public static final int timestampToDateBytes(byte[] buffer,
                                                  int offset,
-                                                 java.sql.Timestamp timestamp) throws ConversionException {
+                                                 java.sql.Timestamp timestamp) throws SqlException {
         int year = timestamp.getYear() + 1900;
         if (year > 9999) {
-            throw new ConversionException("Year exceeds the maximum \"9999\".");
+            throw new SqlException(null,
+                new MessageId(SQLState.YEAR_EXCEEDS_MAXIMUM),
+                new Integer(year), "9999");
         }
         int month = timestamp.getMonth() + 1;
         int day = timestamp.getDate();
@@ -603,10 +615,12 @@
      */
     public static final int dateToTimestampBytes(byte[] buffer,
                                                  int offset,
-                                                 java.sql.Date date) throws ConversionException {
+                                                 java.sql.Date date) throws SqlException {
         int year = date.getYear() + 1900;
         if (year > 9999) {
-            throw new ConversionException("Year exceeds the maximum \"9999\".");
+            throw new SqlException(null,
+                new MessageId(SQLState.YEAR_EXCEEDS_MAXIMUM),
+                new Integer(year), "9999");
         }
         int month = date.getMonth() + 1;
         int day = date.getDate();

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Decimal.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/Decimal.java?rev=395484&r1=395483&r2=395484&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Decimal.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Decimal.java Wed Apr 19 21:59:30 2006
@@ -19,6 +19,9 @@
 */
 package org.apache.derby.client.am;
 
+import org.apache.derby.shared.common.reference.SQLState;
+import org.apache.derby.shared.common.i18n.MessageUtil;
+
 /**
  * Converters from fixed point decimal bytes to <code>java.math.BigDecimal</code>, <code>double</code>, or
  * <code>long</code>.
@@ -28,6 +31,9 @@
      * Packed Decimal representation
      */
     public final static int PACKED_DECIMAL = 0x30;
+    
+    private static MessageUtil msgutil = new MessageUtil(
+        SqlException.CLIENT_MESSAGE_RESOURCE_NAME);
 
     //--------------------------private constants---------------------------------
 
@@ -243,7 +249,8 @@
             return new java.math.BigDecimal(new java.math.BigInteger(signum, magnitude), scale);
         } else {
             // throw an exception here if nibbles is greater than 31
-            throw new java.lang.IllegalArgumentException("Decimal may only be up to 31 digits!");
+            throw new java.lang.IllegalArgumentException(
+                msgutil.getTextMessage(SQLState.DECIMAL_TOO_MANY_DIGITS));
         }
     }
 
@@ -304,7 +311,8 @@
                     hi * Math.pow(10, 27 - scale));
         } else {
             // throw an exception here if nibbles is greater than 31
-            throw new java.lang.IllegalArgumentException("Decimal may only be up to 31 digits!");
+            throw new java.lang.IllegalArgumentException(
+                msgutil.getTextMessage(SQLState.DECIMAL_TOO_MANY_DIGITS));
         }
     }
 
@@ -319,7 +327,8 @@
                                      int scale) throws java.io.UnsupportedEncodingException {
         if (precision > 31) {
             // throw an exception here if nibbles is greater than 31
-            throw new java.lang.IllegalArgumentException("Decimal may only be up to 31 digits!");
+            throw new java.lang.IllegalArgumentException(
+                msgutil.getTextMessage(SQLState.DECIMAL_TOO_MANY_DIGITS));
         }
 
         // The byte-length of a packed decimal with precision <code>p</code> is always <code>p/2 + 1</code>
@@ -361,10 +370,11 @@
                                                            java.math.BigDecimal b,
                                                            int declaredPrecision,
                                                            int declaredScale)
-            throws ConversionException {
+            throws SqlException {
         // packed decimal may only be up to 31 digits.
         if (declaredPrecision > 31) {
-            throw new ConversionException("Packed decimal may only be up to 31 digits!");
+            throw new SqlException(null,
+                new MessageId(SQLState.DECIMAL_TOO_MANY_DIGITS));
         }
 
         // get absolute unscaled value of the BigDecimal as a String.
@@ -374,11 +384,9 @@
         int bigPrecision = unscaledStr.length();
 
         if (bigPrecision > 31) {
-            throw new ConversionException("The numeric literal \"" +
-                    b.toString() +
-                    "\" is not valid because its value is out of range.",
-                    "42820",
-                    -405);
+            throw new SqlException(null,
+                new MessageId(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE),
+                "packed decimal", new SqlCode(-405));
         }
 
         int bigScale = b.scale();
@@ -387,11 +395,9 @@
             // if whole integer part exists, check if overflow.
             int declaredWholeIntegerLength = declaredPrecision - declaredScale;
             if (bigWholeIntegerLength > declaredWholeIntegerLength) {
-                throw new ConversionException("Overflow occurred during numeric data type conversion of \"" +
-                        b.toString() +
-                        "\".",
-                        "22003",
-                        -413);
+                throw new SqlException(null,
+                    new MessageId(SQLState.NUMERIC_OVERFLOW),
+                    b.toString(), "packed decimal", new SqlCode(-413));
             }
         }
 

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/DisconnectException.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/DisconnectException.java?rev=395484&r1=395483&r2=395484&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/DisconnectException.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/DisconnectException.java Wed Apr 19 21:59:30 2006
@@ -21,7 +21,22 @@
 package org.apache.derby.client.am;
 
 public class DisconnectException extends SqlException {
+    public DisconnectException(Agent agent, MessageId msgid, SqlCode sqlcode) {
+        super(agent != null ? agent.logWriter_ : null, msgid, sqlcode);
+    }
 
+    public DisconnectException(Agent agent, MessageId msgid) {
+        super(agent != null ? agent.logWriter_ : null, msgid, 
+            SqlCode.disconnectError);
+        
+        // make the call to close the streams and socket.
+        if (agent != null) {
+            agent.disconnectEvent();
+        }
+    }
+        
+    // Old constructors for backward compatibility until all classes
+    // have been internationalized
     public DisconnectException(Agent agent, String reason, SqlState sqlstate, SqlCode sqlcode) {
         super(agent.logWriter_, reason, sqlstate, sqlcode);
     }

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/SectionManager.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/SectionManager.java?rev=395484&r1=395483&r2=395484&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/SectionManager.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/SectionManager.java Wed Apr 19 21:59:30 2006
@@ -22,6 +22,8 @@
 
 import org.apache.derby.shared.common.reference.JDBC30Translation;
 
+import org.apache.derby.shared.common.reference.SQLState;
+
 
 public class SectionManager {
     String collection_;
@@ -116,7 +118,9 @@
         } else if (resultSetHoldability == JDBC30Translation.CLOSE_CURSORS_AT_COMMIT) {
             return getSection(freeSectionsNonHold_, packageNameWithNoHold__, cursorNamePrefixWithNoHold__, resultSetHoldability);
         } else {
-            throw new SqlException(agent_.logWriter_, "resultSetHoldability property " + resultSetHoldability + " not supported");
+            throw new SqlException(agent_.logWriter_,
+                new MessageId(SQLState.UNSUPPORTED_HOLDABILITY_PROPERTY), 
+                new Integer(resultSetHoldability));
         }
     }
 
@@ -131,7 +135,9 @@
         } else
         // unfortunately we have run out of sections
         {
-            throw new SqlException(agent_.logWriter_, "Run out of sections to use,sections limited to 32k currently");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.EXCEEDED_MAX_SECTIONS),
+                "32k");
         }
     }
 
@@ -183,8 +189,8 @@
     ResultSet getPositionedUpdateResultSet(String cursorName) throws SqlException {
         ResultSet rs = (ResultSet) positionedUpdateCursorNameToResultSet_.get(cursorName);
         if (rs == null) {
-            throw new SqlException(agent_.logWriter_, "ResultSet for cursor " +
-                    cursorName + " is closed.");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.CLIENT_RESULT_SET_NOT_OPEN));
         }
         return (rs.resultSetType_ == java.sql.ResultSet.TYPE_FORWARD_ONLY) ? null : rs;
     }

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlCode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlCode.java?rev=395484&r1=395483&r2=395484&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlCode.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlCode.java Wed Apr 19 21:59:30 2006
@@ -30,7 +30,7 @@
 public class SqlCode {
     private int code_;
 
-    private SqlCode(int code) {
+    public SqlCode(int code) {
         code_ = code;
     }
 
@@ -52,7 +52,7 @@
     public final static SqlCode disconnectError = new SqlCode(-4499);
 
     public final static SqlCode undefinedError = new SqlCode(-99999);
-
+    
     /** SQL code for SQL state 02000 (end of data). DRDA does not
      * specify the SQL code for this SQL state, but Derby uses 100. */
     public final static SqlCode END_OF_DATA = new SqlCode(100);

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlException.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlException.java?rev=395484&r1=395483&r2=395484&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlException.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlException.java Wed Apr 19 21:59:30 2006
@@ -86,6 +86,11 @@
     public static String CLIENT_MESSAGE_RESOURCE_NAME =
         "org.apache.derby.loc.clientmessages";
     
+    // Constants for message ids used in text we print out -- not used
+    // in SqlExceptions
+    public static final String CAUSED_BY_EXCEPTION_ID           = "J106";
+    public static final String BATCH_POSITION_ID                = "J107";
+    
     //SQLException factory initialised with default factory
     //It will be over written by the SQLException factory of the 
     //supported jdbc version    
@@ -125,6 +130,30 @@
             this.setThrowable(cause);
         }
     }
+    
+    /**
+     * Use this to override the standard error code that is derived
+     * from the message severity
+     */
+    public SqlException(LogWriter logWriter, MessageId msgid, Object[] args,
+        SqlCode sqlcode) {
+        this(logWriter, msgid, args);
+        this.errorcode_ = sqlcode.getCode();
+    }
+        
+    public SqlException(LogWriter logWriter, MessageId msgid, SqlCode sqlcode) {
+        this(logWriter, msgid, (Object[])null, sqlcode);
+    }
+    
+    public SqlException(LogWriter logWriter, MessageId msgid, Object arg1,
+        SqlCode sqlcode) {
+        this(logWriter, msgid, new Object[] {arg1}, sqlcode);
+    }
+        
+    public SqlException(LogWriter logWriter, MessageId msgid, Object arg1,
+        Object arg2, SqlCode sqlcode) {
+        this(logWriter, msgid, new Object[] {arg1, arg2}, sqlcode);
+    }
  
     public SqlException (LogWriter logwriter, 
             MessageId msgid, Throwable cause) {
@@ -225,7 +254,8 @@
             // by getMessage() when it composes the message string.
             if (JVMInfo.JDK_ID < JVMInfo.J2SE_14 )
             {
-                causeString_ = " Caused by exception " + 
+                causeString_ = " " + 
+                    msgutil_.getTextMessage(CAUSED_BY_EXCEPTION_ID)  + " " +
                     throwable.getClass() + ": " + throwable.getMessage();
             }
             else
@@ -331,7 +361,8 @@
     // when getMessage() is called.
     // Called by the Agent.
     void setBatchPositionLabel(int index) {
-        batchPositionLabel_ = "Error for batch element #" + index + ": ";
+        batchPositionLabel_ = msgutil_.getTextMessage(BATCH_POSITION_ID) + 
+            index + ": ";
     }
 
     public Sqlca getSqlca() {
@@ -467,31 +498,6 @@
 }
 
 // An intermediate exception encapsulation to provide code-reuse
-// for common ResultSet and ResultSetMetaData column access exceptions.
-
-class ColumnIndexOutOfBoundsException extends SqlException {
-    ColumnIndexOutOfBoundsException(LogWriter logWriter, Throwable throwable, int resultSetColumn) {
-        super(logWriter, throwable,
-                "Invalid argument:" +
-                " Result column index " + resultSetColumn + " is out of range.");
-    }
-}
-
-// An intermediate exception encapsulation to provide code-reuse
-// for common ResultSet data conversion exceptions.
-
-class NumberFormatConversionException extends SqlException {
-    NumberFormatConversionException(LogWriter logWriter, String instance) {
-        super(logWriter,
-                "Invalid data conversion:" +
-                " Result column instance " +
-                instance +
-                " is either an invalid numeric representation" +
-                " or is out of range.");
-    }
-}
-
-// An intermediate exception encapsulation to provide code-reuse
 // for common ResultSet data conversion exceptions.
 
 class ColumnTypeConversionException extends SqlException {
@@ -508,9 +514,7 @@
 
 class LossOfPrecisionConversionException extends SqlException {
     LossOfPrecisionConversionException(LogWriter logWriter, String instance) {
-        super(logWriter,
-                "Invalid data conversion:" +
-                "Requested conversion would result in a loss of precision of " +
-                instance);
+        super(logWriter, new MessageId(SQLState.LOSS_OF_PRECISION_EXCEPTION), 
+            instance);
     }
 }

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java?rev=395484&r1=395483&r2=395484&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java Wed Apr 19 21:59:30 2006
@@ -22,6 +22,7 @@
 import java.sql.SQLException;
 
 import org.apache.derby.shared.common.reference.JDBC30Translation;
+import org.apache.derby.shared.common.reference.SQLState;
 
 public class Statement implements java.sql.Statement, StatementCallbackInterface, UnitOfWorkListener {
 
@@ -320,8 +321,9 @@
             resultSetType_ = type;
             break;
         default:
-            throw new SqlException(agent_.logWriter_, "Invalid argument: " +
-                    "ResultSet Type " + type + " is invalid.");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.INVALID_API_PARAMETER),
+                new Integer(type), "type", "createStatement()");
         }
 
         switch (concurrency) {
@@ -330,8 +332,10 @@
             resultSetConcurrency_ = concurrency;
             break;
         default:
-            throw new SqlException(agent_.logWriter_, "Invalid argument: " +
-                    "ResultSet Concurrency " + concurrency + " is invalid.");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.INVALID_API_PARAMETER),
+                new Integer(concurrency), "concurrency",
+                "createStatement()");
         }
 
         switch (holdability) {
@@ -340,8 +344,10 @@
             resultSetHoldability_ = holdability;
             break;
         default:
-            throw new SqlException(agent_.logWriter_, "Invalid argument: " +
-                    "ResultSet holdability " + holdability + " is invalid.");
+            throw new SqlException(agent_.logWriter_,
+                new MessageId(SQLState.INVALID_API_PARAMETER),
+                new Integer(holdability), "holdability",
+                "createStatement()");
         }
 
         switch (autoGeneratedKeys) {
@@ -350,9 +356,10 @@
             autoGeneratedKeys_ = autoGeneratedKeys;
             break;
         default:
-            throw new SqlException(agent_.logWriter_, "Invalid argument: " +
-                    "Statement auto-generated keys value " + autoGeneratedKeys +
-                    " is invalid.");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.INVALID_API_PARAMETER),
+                new Integer(autoGeneratedKeys),
+                "autoGeneratedKeys", "createStatement");
         }
 
         generatedKeysColumnNames_ = columnNames;
@@ -408,15 +415,15 @@
     void checkExecuteQueryPostConditions(String jdbcStatementInterfaceName) throws SqlException {
         // We'll just rely on finalizers to close the dangling result sets.
         if (resultSetList_ != null && resultSetList_.length != 1) {
-            throw new SqlException(agent_.logWriter_, jdbcStatementInterfaceName + ".executeQuery() cannot be called " +
-                    "because multiple result sets were returned." +
-                    " Use " + jdbcStatementInterfaceName + ".execute() to obtain multiple results.");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.MULTIPLE_RESULTS_ON_EXECUTE_QUERY),
+                jdbcStatementInterfaceName, jdbcStatementInterfaceName);
         }
 
         if (resultSet_ == null) {
-            throw new SqlException(agent_.logWriter_, jdbcStatementInterfaceName + ".executeQuery() was called " +
-                    "but no result set was returned." +
-                    " Use " + jdbcStatementInterfaceName + ".executeUpdate() for non-queries.");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.USE_EXECUTE_UPDATE_WITH_NO_RESULTS),
+                jdbcStatementInterfaceName, jdbcStatementInterfaceName);
         }
     }
 
@@ -450,16 +457,15 @@
     void checkExecuteUpdatePostConditions(String jdbcStatementInterfaceName) throws SqlException {
         // We'll just rely on finalizers to close the dangling result sets.
         if (resultSetList_ != null) {
-            throw new SqlException(agent_.logWriter_, jdbcStatementInterfaceName + ".executeUpdate() cannot be called " +
-                    "because multiple result sets returned." +
-                    " Use " + jdbcStatementInterfaceName + ".execute() to obtain multiple results.");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.MULTIPLE_RESULTS_ON_EXECUTE_QUERY),
+                jdbcStatementInterfaceName, jdbcStatementInterfaceName);
         }
 
         // We'll just rely on the finalizer to close the dangling result set.
         if (resultSet_ != null) {
-            throw new SqlException(agent_.logWriter_, jdbcStatementInterfaceName + ".executeUpdate() was called " +
-                    "but a result set was returned." +
-                    " Use " + jdbcStatementInterfaceName + ".executeQuery() to obtain a result set.");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.LANG_INVALID_CALL_TO_EXECUTE_UPDATE));
         }
     }
 
@@ -560,7 +566,9 @@
                 }
                 checkForClosedStatement();
                 if (max < 0) {
-                    throw new SqlException(agent_.logWriter_, "Invalid maxFieldSize value: " + max);
+                    throw new SqlException(agent_.logWriter_, 
+                        new MessageId(SQLState.INVALID_MAXFIELD_SIZE),
+                        new Integer(max));
                 }
                 maxFieldSize_ = max;
             }
@@ -595,7 +603,9 @@
                 }
                 checkForClosedStatement(); // Per jdbc spec (see java.sql.Statement.close() javadoc)
                 if (maxRows < 0) {
-                    throw new SqlException(agent_.logWriter_, "Invalid maxRows value: " + maxRows);
+                    throw new SqlException(agent_.logWriter_, 
+                        new MessageId(SQLState.INVALID_MAX_ROWS_VALUE),
+                        new Integer(maxRows));
                 }
                 maxRows_ = maxRows;
             }
@@ -647,8 +657,8 @@
                 checkForClosedStatement(); // Per jdbc spec (see java.sql.Statement.close() javadoc)
                 if (seconds < 0) {
                     throw new SqlException(agent_.logWriter_,
-                                           "Attempt to set a negative query timeout",
-                                           "XJ074.S");
+                        new MessageId(SQLState.INVALID_QUERYTIMEOUT_VALUE),
+                        new Integer(seconds));
                 }
                 if (seconds != timeout_) {
                     timeout_ = seconds;
@@ -669,7 +679,8 @@
                 agent_.logWriter_.traceEntry(this, "cancel");
             }
             checkForClosedStatement(); // Per jdbc spec (see java.sql.Statement.close() javadoc)
-            throw new SqlException(agent_.logWriter_, "cancel() not supported by server");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.CANCEL_NOT_SUPPORTED_BY_SERVER));
         }
         catch ( SqlException se )
         {
@@ -712,18 +723,22 @@
                 }
                 checkForClosedStatement(); // Per jdbc spec (see java.sql.Statement.close() javadoc)
                 if (name == null || name.equals("")) {
-                    throw new SqlException(agent_.logWriter_, "Invalid cursor name.");
+                    throw new SqlException(agent_.logWriter_, 
+                        new MessageId(SQLState.CURSOR_INVALID_NAME),
+                        name);
                 }
 
                 // Invalid to set the cursor name if there are ResultSet's open on the Statement.
                 if (resultSet_ != null && resultSet_.openOnClient_) {
-                    throw new SqlException(agent_.logWriter_, "Invalid operation: setCursorName() " +
-                            "called when there are open ResultSet's on the Statement.");
+                    throw new SqlException(agent_.logWriter_, 
+                        new MessageId(SQLState.LANG_CANT_INVALIDATE_OPEN_RESULT_SET),
+                        "setCursorName()", "Statement");
                 }
 
                 // Duplicate cursor names not allowed.
                 if (connection_.clientCursorNameCache_.containsKey(name)) {
-                    throw new SqlException(agent_.logWriter_, "Duplicate cursor names are not allowed.");
+                    throw new SqlException(agent_.logWriter_, 
+                        new MessageId(SQLState.CURSOR_DUPLICATE_NAME), name);
                 }
                 connection_.clientCursorNameCache_.put(name, name);
 
@@ -850,7 +865,9 @@
                     fetchDirection_ = direction;
                     break;
                 default:
-                    throw new SqlException(agent_.logWriter_, "Invalid fetch direction " + direction);
+                    throw new SqlException(agent_.logWriter_,
+                        new MessageId(SQLState.INVALID_FETCH_DIRECTION),
+                        new Integer(direction));
                 }
             }
         }
@@ -885,7 +902,9 @@
                 checkForClosedStatement(); // Per jdbc spec (see java.sql.Statement.close() javadoc)
 
                 if (rows < 0 || (maxRows_ != 0 && rows > maxRows_)) {
-                    throw new SqlException(agent_.logWriter_, "Invalid fetch size " + rows).getSQLException();
+                    throw new SqlException(agent_.logWriter_, 
+                        new MessageId(SQLState.INVALID_ST_FETCH_SIZE),
+                        new Integer(rows)).getSQLException();
                 }
                 fetchSize_ = rows;
             }
@@ -1132,7 +1151,9 @@
                 agent_.logWriter_.traceEntry(this, "executeUpdate", sql, columnIndexes);
             }
             checkForClosedStatement();
-            throw new SqlException(agent_.logWriter_, "Driver not capable");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.NOT_IMPLEMENTED),
+                "executeUpdate(String, int[])");
         }
         catch ( SqlException se )
         {
@@ -1189,7 +1210,9 @@
                 agent_.logWriter_.traceEntry(this, "execute", sql, columnIndexes);
             }
             checkForClosedStatement();
-            throw new SqlException(agent_.logWriter_, "Driver not capable");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.NOT_IMPLEMENTED),
+                "execute(String, int[])");
         }
         catch ( SqlException se )
         {
@@ -1826,8 +1849,9 @@
                 if (cursorName != null) {
                     newSection = agent_.sectionManager_.getPositionedUpdateSection(cursorName, true); // true means get an execute immediate section
                     if (newSection == null) {
-                        throw new SqlException(agent_.logWriter_, "Invalid cursor name \"" + cursorName +
-                                "\" in the Update/Delete statement.");
+                        throw new SqlException(agent_.logWriter_, 
+                            new MessageId(SQLState.CURSOR_INVALID_NAME),
+                            cursorName);
                     }
                     scrollableRS = agent_.sectionManager_.getPositionedUpdateResultSet(cursorName);
                     // do not need to reposition for rowset cursors
@@ -1966,8 +1990,9 @@
             //  If we hear from Sun that we can just set a warning for this, then move this code to the ResultSet constructor.
             // Throw an exception if holdability returned by the server is different from requested.
             if (resultSet_ != null && resultSet_.resultSetHoldability_ != resultSetHoldability_ && sqlMode_ != isCall__) {
-                throw new SqlException(agent_.logWriter_, "Unable to open resultSet with requested " +
-                        "holdability " + resultSetHoldability_ + ".");
+                throw new SqlException(agent_.logWriter_, 
+                    new MessageId(SQLState.UNABLE_TO_OPEN_RS_WITH_REQUESTED_HOLDABILITY),
+                    new Integer(resultSetHoldability_));
             }
 
         // In the case of executing a call to a stored procedure.
@@ -2065,8 +2090,7 @@
         catch (SqlException e) {
             chainBreaker = e;
             chainBreaker.setNextException(new SqlException(agent_.logWriter_,
-                    "Non-recoverable chain-breaking exception occurred during batch processing.  " +
-                    "The batch is terminated non-atomically."));
+                new MessageId(SQLState.BATCH_CHAIN_BREAKING_EXCEPTION)));
         }
         // We need to clear the batch before any exception is thrown from agent_.endBatchedReadChain().
         batch_.clear();
@@ -2172,7 +2196,8 @@
         }
 
         if (!tokenizer.hasMoreTokens()) {
-            throw new SqlException(agent_.logWriter_, "SQL passed with no tokens");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.NO_TOKENS_IN_SQL_TEXT), sql);
         }
 
         sqlUpdateMode_ = 0;
@@ -2207,14 +2232,17 @@
     String getProcedureName(String sql) throws SqlException {
         java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(sql, "\t\n\r\f= (?");
         if (!tokenizer.hasMoreTokens()) {
-            throw new SqlException(agent_.logWriter_, "bugcheck");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.NO_TOKENS_IN_SQL_TEXT), sql);
         }
         String firstToken = tokenizer.nextToken();
         if (!firstToken.equalsIgnoreCase("call")) {
-            throw new SqlException(agent_.logWriter_, "bugcheck");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.LANG_INVALID_CALL_STATEMENT));
         }
         if (!tokenizer.hasMoreTokens()) {
-            throw new SqlException(agent_.logWriter_, "Invalid CALL syntax");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.LANG_INVALID_CALL_STATEMENT));
         }
         return tokenizer.nextToken();
     }
@@ -2244,10 +2272,12 @@
 
     void checkForAppropriateSqlMode(int executeType, int sqlMode) throws SqlException {
         if (executeType == executeQueryMethod__ && sqlMode == isUpdate__) {
-            throw new SqlException(agent_.logWriter_, "executeQuery method cannot be used for update.");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.CANT_USE_EXEC_QUERY_FOR_UPDATE));
         }
         if (executeType == executeUpdateMethod__ && sqlMode == isQuery__) {
-            throw new SqlException(agent_.logWriter_, "executeUpdate method cannot be used for query.");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.LANG_INVALID_CALL_TO_EXECUTE_UPDATE));
         }
     }
 
@@ -2258,9 +2288,14 @@
         // if (!openOnClient_)
         //   throw new SqlException (agent_.logWriter_, "Invalid operation: statement closed");
         //
+        if ( this.connection_ == null || this.connection_.isClosed() )
+            throw new SqlException(agent_.logWriter_,
+                new MessageId(SQLState.NO_CURRENT_CONNECTION));
+        
         if (!openOnClient_) {
             agent_.checkForDeferredExceptions();
-            throw new SqlException(agent_.logWriter_, "Invalid operation: statement closed");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.LANG_STATEMENT_CLOSED_NO_REASON));
         } else {
             agent_.checkForDeferredExceptions();
         }
@@ -2269,7 +2304,8 @@
     // precondition: parseSqlAndSetSqlModes() must be called on the supplied sql string before invoking this method
     void checkForInvalidBatchedSql(String sql) throws SqlException {
         if (sql == null) {
-            throw new SqlException(agent_.logWriter_, "Null batched SQL string passed.");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.NULL_SQL_TEXT));
         }
 
         if (sqlMode_ != isCall__
@@ -2279,7 +2315,8 @@
                 || sqlUpdateMode_ == isUpdateSql__
                 || sqlUpdateMode_ == 0)))// For any undefined pass thru statement like drop create
         {
-            throw new SqlException(agent_.logWriter_, "Invalid SQL in Batch");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.LANG_INVALID_SQL_IN_BATCH), sql);
         }
     }
 
@@ -2478,13 +2515,16 @@
     void checkAutoGeneratedKeysParameters() throws SqlException {
         if (autoGeneratedKeys_ != java.sql.Statement.NO_GENERATED_KEYS &&
                 autoGeneratedKeys_ != java.sql.Statement.RETURN_GENERATED_KEYS) {
-            throw new SqlException(agent_.logWriter_, "Invalid argument: " +
-                    "Statement auto-generated keys value " + autoGeneratedKeys_ +
-                    " is invalid.");
+            throw new SqlException(agent_.logWriter_,
+                new MessageId(SQLState.INVALID_API_PARAMETER),
+                new Integer(autoGeneratedKeys_), "autoGeneratedKeys",
+                "Statement.execute()/executeQuery()");
         }
 
         if (generatedKeysColumnNames_ != null) {
-            throw new SqlException(agent_.logWriter_, "Driver not capable");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.NOT_IMPLEMENTED),
+                "Connection.prepareStatement(String sql, String[] columnNames)");
         }
     }
 
@@ -2585,7 +2625,8 @@
             if ( checkStatement )
                 checkForClosedStatement();
             
-            throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.JDBC_METHOD_NOT_IMPLEMENTED));
         }
         catch ( SqlException se )
         {

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Utils.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/Utils.java?rev=395484&r1=395483&r2=395484&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Utils.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Utils.java Wed Apr 19 21:59:30 2006
@@ -21,6 +21,8 @@
 package org.apache.derby.client.am;
 
 import java.sql.SQLException;
+import org.apache.derby.iapi.types.SQLBit;
+import org.apache.derby.shared.common.i18n.MessageUtil;
 
 // Self-contained utilities.
 // Don't reference any other driver classes, except Configuration, from within this class.
@@ -80,7 +82,10 @@
         byte[] bBytes = decimal.unscaledValue().abs().toByteArray();
 
         if (byteArrayCmp(bBytes, tenRadixArr[tenRadixArr.length - 1]) >= 0) {
-            throw new java.lang.IllegalArgumentException("Precision exceeds 31 digits!");
+            throw new java.lang.IllegalArgumentException(
+                MessageUtil.getCompleteMessage("J105",
+                    SqlException.CLIENT_MESSAGE_RESOURCE_NAME,
+                    (Object[])null));
         }
 
         int lo = 0, hi = tenRadixArr.length - 1, mi = (hi + lo) / 2;

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Version.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/Version.java?rev=395484&r1=395483&r2=395484&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Version.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Version.java Wed Apr 19 21:59:30 2006
@@ -20,9 +20,18 @@
 
 package org.apache.derby.client.am;
 
+import org.apache.derby.shared.common.i18n.MessageUtil;
+
 
 
 public abstract class Version {
+    static MessageUtil msgutil = 
+        new MessageUtil(SqlException.CLIENT_MESSAGE_RESOURCE_NAME);
+    
+    // Constants for internationalized message ids
+    private static String SECURITY_MANAGER_NO_ACCESS_ID             = "J108";
+    private static String UNKNOWN_HOST_ID                           = "J109";
+    
     // Same as java.sql.DatabaseMetaData.getDriverName()
     public static String getDriverName() {
         return Configuration.dncDriverName;
@@ -142,7 +151,8 @@
                 printWriter.println(header + prefix + result);
                 printWriter.flush();
             } catch (SecurityException e) {
-                printWriter.println(header + "Security manager does not permit access to system property " + property);
+                printWriter.println(header + 
+                    msgutil.getTextMessage(SECURITY_MANAGER_NO_ACCESS_ID, property));
                 printWriter.flush();
             }
         }
@@ -158,10 +168,8 @@
                 printWriter.println(java.net.InetAddress.getLocalHost().toString());
                 printWriter.flush();
             } catch (java.net.UnknownHostException e) {
-                printWriter.print(header + "Detected an improper TCP/IP client configuration.");
-                printWriter.print(header + "Unable to determine the IP address of your local host: ");
-                printWriter.print(e.getMessage());
-                printWriter.println(header + "Make sure your client machine has a properly configured IP address.");
+                printWriter.println(header + 
+                    msgutil.getTextMessage(UNKNOWN_HOST_ID, e.getMessage()));
                 printWriter.flush();
             }
         }

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/Request.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/net/Request.java?rev=395484&r1=395483&r2=395484&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/Request.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/Request.java Wed Apr 19 21:59:30 2006
@@ -1518,24 +1518,14 @@
                                int declaredPrecision,
                                int declaredScale) throws SqlException {
         ensureLength(offset_ + 16);
-        try {
-            int length = org.apache.derby.client.am.Decimal.bigDecimalToPackedDecimalBytes(bytes_, offset_, v, declaredPrecision, declaredScale);
-            offset_ += length;
-        } catch (org.apache.derby.client.am.ConversionException e) {
-            throw new SqlException(netAgent_.logWriter_, e,
-                    "BigDecimal conversion exception " + e.getMessage() + ". See attached Throwable.");
-        }
+        int length = org.apache.derby.client.am.Decimal.bigDecimalToPackedDecimalBytes(bytes_, offset_, v, declaredPrecision, declaredScale);
+        offset_ += length;
     }
 
     final void writeDate(java.sql.Date date) throws SqlException {
-        try {
-            ensureLength(offset_ + 10);
-            org.apache.derby.client.am.DateTime.dateToDateBytes(bytes_, offset_, date);
-            offset_ += 10;
-        } catch (org.apache.derby.client.am.ConversionException e) {
-            throw new SqlException(netAgent_.logWriter_, e,
-                    "Date conversion exception " + e.getMessage() + ". See attached Throwable.");
-        }
+        ensureLength(offset_ + 10);
+        org.apache.derby.client.am.DateTime.dateToDateBytes(bytes_, offset_, date);
+        offset_ += 10;
     }
 
     final void writeTime(java.sql.Time time) throws SqlException {
@@ -1545,14 +1535,9 @@
     }
 
     final void writeTimestamp(java.sql.Timestamp timestamp) throws SqlException {
-        try {
-            ensureLength(offset_ + 26);
-            org.apache.derby.client.am.DateTime.timestampToTimestampBytes(bytes_, offset_, timestamp);
-            offset_ += 26;
-        } catch (org.apache.derby.client.am.ConversionException e) {
-            throw new SqlException(netAgent_.logWriter_, e,
-                    "Timestamp conversion exception " + e.getMessage() + ". See attached Throwable.");
-        }
+        ensureLength(offset_ + 26);
+        org.apache.derby.client.am.DateTime.timestampToTimestampBytes(bytes_, offset_, timestamp);
+        offset_ += 26;
     }
 
     // insert a java boolean into the buffer.  the boolean is written

Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties?rev=395484&r1=395483&r2=395484&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties Wed Apr 19 21:59:30 2006
@@ -43,6 +43,7 @@
 08000=Connection closed by unknown interrupt.
 08000.S.1=Cannot close a connection with an active transaction.  The transaction remains open and the connection was not closed.
 
+
 #../java/com/ibm/db2j/protocol/BasicServices/LockManager/messages.properties
 40001=A lock could not be obtained due to a deadlock, cycle of locks and waiters is:\n{0}. The selected victim is XID : {1}.
 
@@ -371,6 +372,9 @@
 22001=A truncation error was encountered trying to shrink {0} ''{1}'' to length {2}.
 54006=The length resulting from {0} operation is greater than {1}.
 22003=The resulting value is outside the range for the data type {0}.
+22003.S.1=Year ({0}) exceeds the maximum ''{1}''.
+22003.S.2=Decimal may only be up to 31 digits.
+22003.S.3=Overflow occurred during numeric data type conversion of ''{0}'' to {1}.
 22005=An attempt was made to get a data value of type ''{0}'' from a data value of type ''{1}''.
 22005.S.1=Unable to convert a value of type ''{0}'' to type ''{1}'' : the encoding is not supported.
 22005.S.2=The required character converter is not available.
@@ -382,6 +386,7 @@
 22013=Attempt to take the square root of a negative number, ''{0}''.
 22014=The start position for LOCATE is invalid; it must be a positive integer. The index  to start the search from is ''{2}''.  The string to search for is ''{0}''.  The string to search from is ''{1}''. 
 22015=The ''{0}'' function is not allowed on the following set of types.  First operand is of type ''{1}''.  Second operand is of type ''{2}''.  Third operand (start position) is of type ''{3}''.
+22015.S.1= Invalid data conversion: requested conversion would result in a loss of precision of {0}
 22018=Invalid character string format for type {0}.
 22019=Invalid escape sequence, ''{0}''. The escape string must be exactly one character. It cannot be a null or more than one character.
 22025=Escape character must be followed by escape character, '_', or '%'. It cannot be followed by any other character or be at the end of the pattern.
@@ -532,6 +537,8 @@
 42Y01=Constraint ''{0}'' is invalid.
 42Y03=''{0}'' is not recognized as a function or procedure.
 42ZA0=Statement too complex. Try rewriting the query to remove complexity. Eliminating many duplicate expressions or breaking up the query and storing interim results in a temporary table can often help resolve this error.
+42ZA1=Invalid SQL in Batch: ''{0}''.
+
 
 # EXTERNAL NAME is SQL keyword - do not translate
 42Y04=Cannot create a procedure or function with EXTERNAL NAME ''{0}'' because it is not a list separated by periods. The expected format is <full java path>.<method name>.
@@ -1179,9 +1186,27 @@
 XJ126.S=This method should not be called on sensitive dynamic cursors.
 XJ128.S=Unable to unwrap for ''{0}''
 
+XJ200.S=Exceeded maximum number of sections {0}
+XJ201.S={0}.executeQuery() cannot be called because multiple result sets were returned.  Use {1}.execute() to obtain multiple results.
+XJ202.S=Invalid cursor name ''{0}''.
+XJ203.S=Cursor name ''{0}'' is already in use
+XJ204.S=Unable to open result set with requested holdability {0}.
+XJ205.S={0}.executeQuery() was called but no result set was returned. Use {1}.executeUpdate() for non-queries."
+XJ206.S=SQL text ''{0}'' has no tokens.
+XJ207.S=executeQuery method can not be used for update.
+XJ208.S=Non-atomic batch failure.  The batch was submitted, but at least one exception occurred on an individual member of the batch. Use getNextException() to retrieve the exceptions for specific batched elements.
+XJ209.S=The required stored procedure is not installed on the server.
+XJ210.S=The load module name for the stored procedure on the server is not found.
+XJ211.S=Non-recoverable chain-breaking exception occurred during batch processing. The batch is terminated non-atomically.
+
+
+
+# 0A - SQLState class indicating feature not supported
 0A000.S=Feature not implemented: {0}.
 0A000.S.1=JDBC method is not yet implemented.
 0A000.S.2=JDBC method {0} is not supported by the server. Please upgrade the server.
+0A000.S.3=resultSetHoldability property {0} not supported
+0A000.S.4=cancel() not supported by the server.
 
 
 XJ004.C=Database ''{0}'' not found.
@@ -1203,6 +1228,7 @@
 XXXXX.C.6=Normal database session close.
 
 08006.D=Database ''{0}'' shutdown.
+08006.C.1=An error occurred during connect reset and the connection has been terminated.  See chained exceptions for details.
 
 XJ015.M=Derby system shutdown.
 
@@ -1316,6 +1342,12 @@
 J102=An exception was thrown during network server startup. {0}
 J103=An exception was thrown during network server shutdown. {0}
 J104=The object is already closed.
+J105=Precision exceeds 31 digits!
+J106=Caused by exception
+J107=Error for batch element #
+J108=Security manager does not permit access to system property {0}.
+J109=Detected an improper TCP/IP client configuration.  Unable to determine the IP address of your local host: ''{0}''.  Make sure your client machine has a properly configured IP address.
+
 
 # Authentication
 A001=FATAL: There is no Authentication Service for the system

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=395484&r1=395483&r2=395484&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 Wed Apr 19 21:59:30 2006
@@ -665,6 +665,9 @@
 	String LANG_STRING_TRUNCATION                                      = "22001";
 	String LANG_CONCAT_STRING_OVERFLOW                                      = "54006";
 	String LANG_OUTSIDE_RANGE_FOR_DATATYPE                             = "22003";
+    String YEAR_EXCEEDS_MAXIMUM                                        = "22003.S.1";
+    String DECIMAL_TOO_MANY_DIGITS                                     = "22003.S.2";
+    String NUMERIC_OVERFLOW                                            = "22003.S.3";
 
 	String LANG_DATA_TYPE_GET_MISMATCH                                 = "22005"; // same 22005 error
     String UNSUPPORTED_ENCODING                                        = "22005.S.1";
@@ -678,6 +681,7 @@
     String LANG_SQRT_OF_NEG_NUMBER                                     = "22013";
     String LANG_INVALID_PARAMETER_FOR_SEARCH_POSITION                  = "22014";
     String LANG_INVALID_TYPE_FOR_LOCATE_FUNCTION                       = "22015";
+    String LOSS_OF_PRECISION_EXCEPTION                                 = "22015.S.1";
 	String LANG_FORMAT_EXCEPTION                                       = "22018";
 	String LANG_INVALID_ESCAPE_CHARACTER                               = "22019";
 	String LANG_INVALID_ESCAPE_SEQUENCE                                = "22025";
@@ -1005,6 +1009,7 @@
 	String LANG_UNSUPPORTED_TRIGGER_STMT		   					   = "42Z9D";
     String LANG_DROP_CONSTRAINT_TYPE                                   = "42Z9E";
     String LANG_QUERY_TOO_COMPLEX                                      = "42ZA0";
+    String LANG_INVALID_SQL_IN_BATCH                                   = "42ZA1";
 
 	//following 3 matches the DB2 sql states
 	String LANG_DECLARED_GLOBAL_TEMP_TABLE_ONLY_IN_SESSION_SCHEMA = "428EK";
@@ -1346,6 +1351,9 @@
     String NOT_IMPLEMENTED                                          = "0A000.S";
     String JDBC_METHOD_NOT_IMPLEMENTED                              = "0A000.S.1";
     String JDBC_METHOD_NOT_SUPPORTED_BY_SERVER                      = "0A000.S.2";
+    String UNSUPPORTED_HOLDABILITY_PROPERTY                         = "0A000.S.3";
+    String CANCEL_NOT_SUPPORTED_BY_SERVER                           = "0A000.S.4";
+
 
 	
 
@@ -1485,7 +1493,20 @@
     String CURSOR_INVALID_FOR_SENSITIVE_DYNAMIC = "XJ126.S";
     //wrapper related
     String UNABLE_TO_UNWRAP = "XJ128.S";
-
+    
+    String EXCEEDED_MAX_SECTIONS = "XJ200.S";
+    String MULTIPLE_RESULTS_ON_EXECUTE_QUERY = "XJ201.S";
+    String CURSOR_INVALID_NAME = "XJ202.S";
+    String CURSOR_DUPLICATE_NAME = "XJ203.S";
+    String UNABLE_TO_OPEN_RS_WITH_REQUESTED_HOLDABILITY = "XJ204.S";
+    String USE_EXECUTE_UPDATE_WITH_NO_RESULTS = "XJ205.S";
+    String NO_TOKENS_IN_SQL_TEXT = "XJ206.S";
+    String CANT_USE_EXEC_QUERY_FOR_UPDATE = "XJ207.S";
+    String BATCH_NON_ATOMIC_FAILURE = "XJ208.S";
+    String STORED_PROC_NOT_INSTALLED = "XJ209.S";
+    String STORED_PROC_LOAD_MODULE_NOT_FOUND = "XJ210.S";
+    String BATCH_CHAIN_BREAKING_EXCEPTION = "XJ211.S";
+    
     String INTERNAL_ERROR = "XJ999.S";
     String CONN_GENERIC = "X0RQB.S";
 
@@ -1513,8 +1534,12 @@
     // you *must* add a severity code
     String NOGETCONN_ON_CLOSED_POOLED_CONNECTION = "08003.C.1";
     String LOB_METHOD_ON_CLOSED_CONNECTION = "08003.C.2";
+    
+    // 08006 means connection exception - connection failure
+    String CONNECTION_FAILED_ON_RESET = "08006.C.1";
+        
     // system severity
-    String SHUTDOWN_DATABASE = "08006.D";   
+    String SHUTDOWN_DATABASE = "08006.D";  
         
     //the following 2 exceptions are internal and never get seen by the user.
     String CLOSE_REQUEST = "close.C.1"; // no message in messages.properties as it is never printed

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/autoGeneratedJdbc30.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/autoGeneratedJdbc30.out?rev=395484&r1=395483&r2=395484&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/autoGeneratedJdbc30.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/autoGeneratedJdbc30.out Wed Apr 19 21:59:30 2006
@@ -254,7 +254,7 @@
 PASS - expected exception - Feature not implemented
 Try passing array with Statement.executeUpdate
 PASS -- expected exception
-SQLSTATE(null): Driver not capable
+SQLSTATE(0A000): Feature not implemented: executeUpdate(String, int[]).
 Test21ps - insert select with columnIndexes[] array should fail
 Try passing array with Connection.prepareStatement
 PASS -- expected exception
@@ -262,10 +262,10 @@
 Test22 - insert select with columnNames[] array should fail
 Try passing array with Statement.execute
 PASS -- expected exception
-SQLSTATE(null): Driver not capable
+SQLSTATE(0A000): Feature not implemented: Connection.prepareStatement(String sql, String[] columnNames).
 Try passing array with Statement.executeUpdate
 PASS -- expected exception
-SQLSTATE(null): Driver not capable
+SQLSTATE(0A000): Feature not implemented: Connection.prepareStatement(String sql, String[] columnNames).
 Test22ps - insert select with columnNames[] array should fail
 Try passing array with Connection.prepareStatement
 PASS -- expected exception

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/forupdate.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/forupdate.out?rev=395484&r1=395483&r2=395484&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/forupdate.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/forupdate.out Wed Apr 19 21:59:30 2006
@@ -46,7 +46,7 @@
 ERROR 42X30: Cursor 'SQL_CURLH000C1' not found. Verify that autocommit is OFF.
 ij> --  cursor with same name already exists
 get cursor c as 'select i, v from t1, t2';
-ERROR (no SQLState): Duplicate cursor names are not allowed.
+ERROR XJ203: Cursor name 'C' is already in use
 ij> close c;
 ij> -- . implicit update test for updatable spec
 ----- this will end up being read only; we know because the delete is refused
@@ -513,7 +513,7 @@
 1          
 ij> close curs1;
 ij> execute curs1;
-ERROR (no SQLState): ResultSet for cursor CURS1 is closed.
+ERROR XCL16: ResultSet not open.  Verify that autocommit is OFF.
 ij> -- clean up
 drop table t1;
 0 rows inserted/updated/deleted

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/holdCursorIJ.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/holdCursorIJ.out?rev=395484&r1=395483&r2=395484&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/holdCursorIJ.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/holdCursorIJ.out Wed Apr 19 21:59:30 2006
@@ -215,7 +215,7 @@
 2 |23         
 ij> close jdk4;
 ij> update t1 set c12=234 where current of jdk4;
-ERROR (no SQLState): Invalid cursor name "JDK4" in the Update/Delete statement.
+ERROR XJ202: Invalid cursor name 'JDK4'.
 ij> select * from t1;
 C11 |C12        
 -----
@@ -261,7 +261,7 @@
 -----
 ij> close jdk4;
 ij> delete from t1 where current of jdk4;
-ERROR (no SQLState): Invalid cursor name "JDK4" in the Update/Delete statement.
+ERROR XJ202: Invalid cursor name 'JDK4'.
 ij> select * from t1;
 C11 |C12        
 -----

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/procedure.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/procedure.out?rev=395484&r1=395483&r2=395484&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/procedure.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/procedure.out Wed Apr 19 21:59:30 2006
@@ -271,7 +271,7 @@
 A |B |C                   
 -----
 70 |831 |45.700              
-EXPECTED SQL Exception: BigDecimal conversion exception [converters] Overflow occurred during numeric data type conversion of "10243".. See attached Throwable.
+EXPECTED SQL Exception: Overflow occurred during numeric data type conversion of '10243' to packed decimal.
 A |B |C                   
 -----
 80 |993 |1234.567            
@@ -352,7 +352,7 @@
 No ResultSet or update count returned
 OP4INOUT 9+23.505 >32.50< null ? false
 EXPECTED SQL Exception: The resulting value is outside the range for the data type DECIMAL/NUMERIC(4,2).
-EXPECTED SQL Exception: BigDecimal conversion exception [converters] Overflow occurred during numeric data type conversion of "102.33".. See attached Throwable.
+EXPECTED SQL Exception: Overflow occurred during numeric data type conversion of '102.33' to packed decimal.
 EXPECTED SQL Exception: (07000) At least one parameter to the current statement is uninitialized.
 SQL Control
 CREATE PROCEDURE SQLC.SQLCONTROL1_0 (OUT E1 VARCHAR(128), OUT E2 VARCHAR(128), OUT E3 VARCHAR(128), OUT E4 VARCHAR(128), OUT E5 VARCHAR(128), OUT E6 VARCHAR(128), OUT E7 VARCHAR(128))  PARAMETER STYLE JAVA LANGUAGE JAVA EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.ProcedureTest.sqlControl'

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/updatableResultSet.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/updatableResultSet.out?rev=395484&r1=395483&r2=395484&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/updatableResultSet.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/updatableResultSet.out Wed Apr 19 21:59:30 2006
@@ -272,15 +272,15 @@
 But it fails under Network Server mode because JCC and Derby Net Client do not allow statement name change when there an open resultset against it
 change the cursor name(case sensitive name) with setCursorName and then try to deleteRow
 change the cursor name one more time with setCursorName and then try to deleteRow
-SQL State : null
-Got expected exception Invalid operation: setCursorName() called when there are open ResultSet's on the Statement.
+SQL State : X0X95
+Got expected exception Operation 'setCursorName()' cannot be performed on object 'Statement' because there is an open ResultSet dependent on that object.
 Positive Test8b - change the name of the statement when the resultset is open and see if updateRow still works
 This test works in embedded mode since Derby can handle the change in the name of the statement with an open resultset
 But it fails under Network Server mode because JCC and Derby Net Client do not allow statement name change when there an open resultset against it
 change the cursor name one more time with setCursorName and then try to updateRow
 change the cursor name(case sensitive name) with setCursorName and then try to updateRow
-SQL State : null
-Got expected exception Invalid operation: setCursorName() called when there are open ResultSet's on the Statement.
+SQL State : X0X95
+Got expected exception Operation 'setCursorName()' cannot be performed on object 'Statement' because there is an open ResultSet dependent on that object.
 Positive Test9a - using correlation name for the table in the select sql works in embedded mode and Network Server using Derby Net Client driver
 Correlation name for table does not work in Network Server mode (using JCC) because the drivers construct the delete sql with the correlation name rather than the base table name
 column 1 on this row is 1