db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davi...@apache.org
Subject svn commit: r370815 [1/2] - in /db/derby/code/trunk: ./ java/build/org/apache/derbyBuild/ java/client/org/apache/derby/client/am/ java/client/org/apache/derby/loc/ java/engine/org/apache/derby/iapi/error/ java/engine/org/apache/derby/iapi/reference/ ja...
Date Fri, 20 Jan 2006 14:26:12 GMT
Author: davidvc
Date: Fri Jan 20 06:25:53 2006
New Revision: 370815

URL: http://svn.apache.org/viewcvs?rev=370815&view=rev
Log:
DERBY-838: Establish an internationalization framework for the network
client.

Added a new shared directory and shared packages.  These shared packages
are only used by the derbyclient.jar until we establish a shared
code framework
M    tools/ant/properties/dirs.properties
A    java/shared
A    java/shared/org
A    java/shared/org/apache
A    java/shared/org/apache/derby
A    java/shared/org/apache/derby/shared
A    java/shared/org/apache/derby/shared/common
A    java/shared/org/apache/derby/shared/common/i18n
AM   java/shared/org/apache/derby/shared/common/i18n/MessageUtil.java
A    java/shared/org/apache/derby/shared/common/error
AM   java/shared/org/apache/derby/shared/common/error/ExceptionSeverity.java
AM   java/shared/org/apache/derby/shared/common/error/ExceptionUtil.java
A    java/shared/org/apache/derby/shared/common/info
AM   java/shared/org/apache/derby/shared/common/info/JVMInfo.java
A    java/shared/org/apache/derby/shared/common/reference
A    java/shared/org/apache/derby/shared/common/reference/SQLState.java
A    java/shared/org/apache/derby/shared/common/reference/JDBC20Translation.java
A    java/shared/org/apache/derby/shared/common/reference/JDBC30Translation.java
AM   java/shared/org/apache/derby/shared/package.html
AM   java/shared/build.xml
M    build.xml

Modified splitmessages to copy messages shared with the client over
to client-messages.properties
M    java/build/org/apache/derbyBuild/splitmessages.java
M    java/engine/org/apache/derby/loc/build.xml

Modified SQLException to have new constructors that take a message 
id
M    java/client/org/apache/derby/client/am/SqlException.java
AM   java/client/org/apache/derby/client/am/MessageId.java

Relocated some reference classes over to the shared framework
D    java/engine/org/apache/derby/iapi/reference/SQLState.java
D    java/engine/org/apache/derby/iapi/reference/JDBC20Translation.java
D    java/engine/org/apache/derby/iapi/reference/JDBC30Translation.java
M    java/engine/org/apache/derby/iapi/error/ExceptionSeverity.java

Added client-specific messages
A    java/client/org/apache/derby/loc
AM   java/client/org/apache/derby/loc/client-messages_en.properties
AM   java/client/org/apache/derby/loc/client-messages.properties

Internationalized some client classes
M    java/client/org/apache/derby/client/am/Blob.java
M    java/client/org/apache/derby/client/am/CallableStatement.java

Fixed test output to handle new messages/SQLStates
M    java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/blobclob4BLOB.out

Added:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/MessageId.java   (with props)
    db/derby/code/trunk/java/client/org/apache/derby/loc/
    db/derby/code/trunk/java/client/org/apache/derby/loc/client-messages.properties   (with props)
    db/derby/code/trunk/java/client/org/apache/derby/loc/client-messages_en.properties   (with props)
    db/derby/code/trunk/java/shared/
    db/derby/code/trunk/java/shared/build.xml   (with props)
    db/derby/code/trunk/java/shared/org/
    db/derby/code/trunk/java/shared/org/apache/
    db/derby/code/trunk/java/shared/org/apache/derby/
    db/derby/code/trunk/java/shared/org/apache/derby/shared/
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/error/
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/error/ExceptionSeverity.java   (with props)
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/error/ExceptionUtil.java   (with props)
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/i18n/
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/i18n/MessageUtil.java   (with props)
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/info/
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/info/JVMInfo.java   (with props)
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/JDBC20Translation.java
      - copied, changed from r370178, db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/JDBC20Translation.java
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/JDBC30Translation.java
      - copied, changed from r370178, db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/JDBC30Translation.java
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
      - copied, changed from r370178, db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/SQLState.java
    db/derby/code/trunk/java/shared/org/apache/derby/shared/package.html   (with props)
Removed:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/JDBC20Translation.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/JDBC30Translation.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/SQLState.java
Modified:
    db/derby/code/trunk/build.xml
    db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Blob.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlException.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/ExceptionSeverity.java
    db/derby/code/trunk/java/engine/org/apache/derby/loc/build.xml
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/blobclob4BLOB.out
    db/derby/code/trunk/tools/ant/properties/dirs.properties

Modified: db/derby/code/trunk/build.xml
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/build.xml?rev=370815&r1=370814&r2=370815&view=diff
==============================================================================
--- db/derby/code/trunk/build.xml (original)
+++ db/derby/code/trunk/build.xml Fri Jan 20 06:25:53 2006
@@ -280,7 +280,7 @@
 <!--                   Derby Engine build target                     -->
 <!-- ==================================================================== -->
 
-  <target name="engine" depends="state,parsers">
+  <target name="engine" depends="shared,state,parsers">
     <ant dir="${derby.engine.src.dir}"/>
     <antcall target="build"/>
     <ant dir="${derby.engine.dir}/loc"/>
@@ -308,11 +308,15 @@
     <ant dir="${derby.tools.src.dir}"/>
   </target>
 
+  <target name="shared" depends="init">
+    <ant dir="${derby.shared.src.dir}"/>
+  </target>
+  
   <target name="drda" depends="engine">
     <ant dir="${derby.drda.src.dir}"/>
   </target>
 
-  <target name="client" depends="engine,init">
+  <target name="client" depends="engine,shared">
     <ant dir="${derby.client.src.dir}"/>
     <antcall target="compile_jdbc4_target">
     	                 <param name="coj.buildscript" value="${derby.client.src.dir}/build.xml"/>
@@ -1120,8 +1124,11 @@
     	 manifest="${derby.jar.dir}/lists/smfclient.mf">
       <fileset dir="${out.dir}"
                includes="org/apache/derby/client/**,
-			org/apache/derby/client/jdbc/Client**,org/apache/derby/jdbc/Client**,org/apache/derby/iapi/services/info/**
-                         org/apache/derby/info/dnc.properties"/>
+			org/apache/derby/client/jdbc/Client**,org/apache/derby/jdbc/Client**,org/apache/derby/iapi/services/info/**,
+                         org/apache/derby/shared/**,
+                         org/apache/derby/info/dnc.properties,
+                         org/apache/derby/loc/client-messages*.properties"
+               excludes="org/apache/derby/shared/common/reference/**"/>
       <fileset dir="${derby.jar.dir}/lists"
                includes="META-INF/**"/>
     </jar>

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=370815&r1=370814&r2=370815&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 Fri Jan 20 06:25:53 2006
@@ -2,7 +2,7 @@
 
    Derby - Class org.apache.derbyBuild.splitmessages
 
-   Copyright 2000, 2004 The Apache Software Foundation or its licensors, as applicable.
+   Copyright 2000, 2006 The Apache Software Foundation or its licensors, as applicable.
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
@@ -30,15 +30,40 @@
 		arg[0] is the destination directory
 		arg[1] is the source file.
 	*/
+    
+    /** 
+     *  This is the list of message ids that are shared between
+     *  the network client and the engine.  This is used to generate
+     *  a set of 'shared' messages.  This avoids us having to maintain
+     *  two separate message files.
+     *
+     *  NOTE: We already assume all message ids starting with XJ are shared.
+     *  This covers 90% of the cases.  Only add ids here if you have a 
+     *  message id that is not in the XJ class.
+     */
+    private static TreeSet clientMessageIds = new TreeSet();
+    
+    /**
+     * Initialize the set of shared message ids
+     */
+    static void initClientMessageIds()
+    {
+        // right now, no message ids that don't start with "XJ",
+        // so nothing to do here.  Once we have some that don't
+        // start with XJ, add here using clientMessageIds.add()
+    }
 
 	public static void main(String[] args) throws Exception {
 
+        initClientMessageIds();
 
 		Properties p = new Properties();
 
 		File dir = new File(args[0]);
 
 		File source = new File(args[1]);
+        File clientDir = new File(args[2]);
+        
 		String s = source.getName();
 		// loose the suffix
 		s = s.substring(0, s.lastIndexOf('.'));
@@ -53,16 +78,41 @@
 		p.load(is);
 		is.close();
 
-
+        
 		Properties[] c = new Properties[50];
 		for (int i = 0; i < 50; i++) {
 			c[i] = new Properties();
 		}
+        
+        Properties clientProps = new Properties();
+
+        // Open the client properties file for the given locale
+        // from the client locales directory, and then intialize
+        // clientProps with what we find in there
+        String clientPropsFileName = "client-messages" + locale + ".properties";
+        try
+        {
+            InputStream clientInStream = new FileInputStream(
+                    new File(clientDir, clientPropsFileName));
+            clientProps.load(clientInStream);
+            clientInStream.close();
+        }
+        catch ( FileNotFoundException fnfe )
+        {
+            // That's fine, it just means there are no client-specfic messages
+            // for this locale yet
+        }
 
 		for (Enumeration e = p.keys(); e.hasMoreElements(); ) {
 			String key = (String) e.nextElement();
 
 			c[MessageService.hashString50(key)].put(key, p.getProperty(key));
+            
+            // If we have a match, add it to the list of client messages
+            if ( isClientMessage(key) )
+            {
+                clientProps.put(key, p.getProperty(key));
+            }
 		}
 
 		for (int i = 0; i < 50; i++) {
@@ -71,10 +121,11 @@
 			OutputStream fos = new BufferedOutputStream(
 				new FileOutputStream(new File(dir, "m"+i+locale+".properties")), 16 * 1024);
 
+            
 			c[i].save(fos, (String) null);
 			fos.flush();
 			fos.close();
-
+            
 			if (addBase) {
 				// add duplicate english file as the base
 				fos = new BufferedOutputStream(
@@ -86,7 +137,57 @@
 
 
 		}
-
+        
 		System.out.println("split messages" + locale);
+
+        // Save the client messages (the combination of what was already
+        // there and what we added from the engine properties file) into
+        // the Derby locales directory
+        OutputStream clientOutStream = new BufferedOutputStream(
+            new FileOutputStream(new File(dir, clientPropsFileName)), 
+            16 * 1024);
+
+        clientProps.save(clientOutStream, (String)null);
+        clientOutStream.flush();
+        clientOutStream.close();
+        
+        if ( addBase )
+        {
+            // Save the English messages as the base
+            clientOutStream = new BufferedOutputStream(
+                new FileOutputStream(new File(dir, "client-messages.properties")), 
+                16 * 1024);
+
+            clientProps.save(clientOutStream, (String)null);
+            clientOutStream.flush();
+            clientOutStream.close();            
+        }
+        System.out.println("Copied client messages for " + locale);
 	}
+    
+    /**
+     * Determine if this is a message that the client is using
+     *
+     * We assume all message ids starting with "XJ" 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
+     * shared messages
+     *
+     * All other shared message ids should be added to the static array
+     * clientMessageIds, defined at the top of this class
+     */
+    static boolean isClientMessage(String messageId)
+    {
+        if ( messageId.startsWith("XJ") )
+        {
+            return true;
+        }
+        
+        if ( clientMessageIds.contains(messageId))
+        {
+            return true;
+        }
+        
+        return false;
+    }
 }

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Blob.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/Blob.java?rev=370815&r1=370814&r2=370815&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Blob.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Blob.java Fri Jan 20 06:25:53 2006
@@ -20,6 +20,8 @@
 
 package org.apache.derby.client.am;
 
+import org.apache.derby.shared.common.reference.SQLState;
+
 public class Blob extends Lob implements java.sql.Blob {
     //-----------------------------state------------------------------------------
 
@@ -76,8 +78,15 @@
             if (agent_.loggingEnabled()) {
                 agent_.logWriter_.traceEntry(this, "getBytes", (int) pos, length);
             }
-            if ((pos <= 0) || (length < 0)) {
-                throw new SqlException(agent_.logWriter_, "Invalid position " + pos + " or length " + length);
+            if (pos <= 0) {
+                throw new SqlException(agent_.logWriter_, 
+                    new MessageId(SQLState.BLOB_BAD_POSITION), 
+                    new Long(pos));
+            }
+            if (length < 0) {
+                throw new SqlException(agent_.logWriter_, 
+                    new MessageId(SQLState.BLOB_NONPOSITIVE_LENGTH),
+                    new Integer(length));
             }
             byte[] retVal = getBytesX(pos, length);
             if (agent_.loggingEnabled()) {
@@ -129,7 +138,8 @@
                 agent_.logWriter_.traceEntry(this, "position(byte[], long)", pattern, start);
             }
             if (pattern == null) {
-                throw new SqlException(agent_.logWriter_, "Search pattern cannot be null.");
+                throw new SqlException(agent_.logWriter_, 
+                    new MessageId(SQLState.BLOB_NULL_PATTERN));
             }
             long pos = positionX(pattern, start);
             if (agent_.loggingEnabled()) {
@@ -151,7 +161,8 @@
                 agent_.logWriter_.traceEntry(this, "position(Blob, long)", pattern, start);
             }
             if (pattern == null) {
-                throw new SqlException(agent_.logWriter_, "Search pattern cannot be null.");
+                throw new SqlException(agent_.logWriter_, 
+                    new MessageId(SQLState.BLOB_NULL_PATTERN));
             }
             long pos = positionX(pattern, start);
             if (agent_.loggingEnabled()) {
@@ -202,13 +213,25 @@
 
     public int setBytesX(long pos, byte[] bytes, int offset, int len) throws SqlException {
         int length = 0;
-        if ((int) pos <= 0 || pos > binaryString_.length - dataOffset_) {
-            throw new SqlException(agent_.logWriter_, "Invalid position " + pos
-                    + " , offset " + offset + " or length " + len);
-        }
-        if ((offset < 0) || offset > bytes.length || len < 0) {
-            throw new SqlException(agent_.logWriter_, "Invalid position " + pos
-                    + " , offset " + offset + " or length " + len);
+        if ((int) pos <= 0) {
+            throw new SqlException(agent_.logWriter_,
+                new MessageId(SQLState.BLOB_BAD_POSITION), new Long(pos));
+        }
+        
+        if ( pos > binaryString_.length - dataOffset_) {
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.BLOB_POSITION_TOO_LARGE), new Long(pos));
+        }
+        if ((offset < 0) || offset > bytes.length )
+        {
+            throw new SqlException(agent_.logWriter_,
+                new MessageId(SQLState.INVALID_BLOB_OFFSET), 
+                new Integer(offset));
+        }
+        if ( len < 0 ) {
+            throw new SqlException(agent_.logWriter_,
+                new MessageId(SQLState.BLOB_NONPOSITIVE_LENGTH),
+                new Integer(length));
         }
         if (len == 0) {
             return 0;
@@ -246,7 +269,9 @@
                 agent_.logWriter_.traceEntry(this, " truncate", (int) len);
             }
             if (len < 0 || len > this.length()) {
-                throw new SqlException(agent_.logWriter_, "Invalid length " + len);
+                throw new SqlException(agent_.logWriter_,
+                    new MessageId(SQLState.INVALID_API_PARAMETER),
+                    new Long(len), "len", "Blob.truncate()");
             }
             if (len == this.length()) {
                 return;

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement.java?rev=370815&r1=370814&r2=370815&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement.java Fri Jan 20 06:25:53 2006
@@ -20,7 +20,7 @@
 
 package org.apache.derby.client.am;
 
-
+import org.apache.derby.shared.common.reference.SQLState;
 
 public class CallableStatement extends PreparedStatement
         implements java.sql.PreparedStatement,
@@ -250,7 +250,8 @@
     private boolean wasNullX() throws SqlException {
         super.checkForClosedStatement();
         if (wasNull_ == WAS_NULL_UNSET) {
-            throw new SqlException(agent_.logWriter_, "Invalid operation: wasNull() called with no data retrieved.");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.WASNULL_INVALID));
         }
         return wasNull_ == WAS_NULL;
     }
@@ -503,7 +504,8 @@
             super.checkForClosedStatement();
             parameterIndex = checkForEscapedCallWithResult(parameterIndex);
             if (parameterIndex == 0 && escapedProcedureCallWithResult_) {
-                throw new SqlException(agent_.logWriter_, "Invalid method call: parameter 1 is an integer OUT parameter returned by the stored procedure, use getInt call.");
+                throw new SqlException(agent_.logWriter_, 
+                    new MessageId(SQLState.INVALID_PARAM_USE_GETINT));
             }
             checkGetterPreconditions(parameterIndex);
             setWasNull(parameterIndex);
@@ -521,7 +523,8 @@
                 agent_.logWriter_.traceEntry(this, "getDate", parameterIndex, cal);
             }
             if (cal == null) {
-                throw new SqlException(agent_.logWriter_, "Invalid parameter: calendar is null");
+                throw new SqlException(agent_.logWriter_, 
+                    new MessageId(SQLState.CALENDAR_IS_NULL));
             }
             java.sql.Date result = getDate(parameterIndex);
             if (result != null) {
@@ -551,7 +554,8 @@
             super.checkForClosedStatement();
             parameterIndex = checkForEscapedCallWithResult(parameterIndex);
             if (parameterIndex == 0 && escapedProcedureCallWithResult_) {
-                throw new SqlException(agent_.logWriter_, "Invalid method call: parameter 1 is an integer OUT parameter returned by the stored procedure, use getInt call.");
+                throw new SqlException(agent_.logWriter_, 
+                    new MessageId(SQLState.INVALID_PARAM_USE_GETINT));
             }
             checkGetterPreconditions(parameterIndex);
             setWasNull(parameterIndex);
@@ -569,7 +573,8 @@
                 agent_.logWriter_.traceEntry(this, "getTime", parameterIndex, cal);
             }
             if (cal == null) {
-                throw new SqlException(agent_.logWriter_, "Invalid parameter: calendar is null");
+                throw new SqlException(agent_.logWriter_, 
+                    new MessageId(SQLState.CALENDAR_IS_NULL));
             }
             java.sql.Time result = getTime(parameterIndex);
             if (result != null) {
@@ -599,7 +604,8 @@
             super.checkForClosedStatement();
             parameterIndex = checkForEscapedCallWithResult(parameterIndex);
             if (parameterIndex == 0 && escapedProcedureCallWithResult_) {
-                throw new SqlException(agent_.logWriter_, "Invalid method call: parameter 1 is an integer OUT parameter returned by the stored procedure, use getInt call.");
+                throw new SqlException(agent_.logWriter_, 
+                    new MessageId(SQLState.INVALID_PARAM_USE_GETINT));
             }
             checkGetterPreconditions(parameterIndex);
             setWasNull(parameterIndex);
@@ -617,7 +623,8 @@
                 agent_.logWriter_.traceEntry(this, "getTimestamp", parameterIndex, cal);
             }
             if (cal == null) {
-                throw new SqlException(agent_.logWriter_, "Invalid parameter: calendar is null");
+                throw new SqlException(agent_.logWriter_, 
+                    new MessageId(SQLState.CALENDAR_IS_NULL));
             }
             java.sql.Timestamp result = getTimestamp(parameterIndex);
             if (result != null) {
@@ -675,7 +682,8 @@
             super.checkForClosedStatement();
             parameterIndex = checkForEscapedCallWithResult(parameterIndex);
             if (parameterIndex == 0 && escapedProcedureCallWithResult_) {
-                throw new SqlException(agent_.logWriter_, "Invalid method call: parameter 1 is an integer OUT parameter returned by the stored procedure, use getInt call.");
+                throw new SqlException(agent_.logWriter_, 
+                    new MessageId(SQLState.INVALID_PARAM_USE_GETINT));
             }
             checkGetterPreconditions(parameterIndex);
             setWasNull(parameterIndex);
@@ -695,7 +703,8 @@
             super.checkForClosedStatement();
             parameterIndex = checkForEscapedCallWithResult(parameterIndex);
             if (parameterIndex == 0 && escapedProcedureCallWithResult_) {
-                throw new SqlException(agent_.logWriter_, "Invalid method call: parameter 1 is an integer OUT parameter returned by the stored procedure, use getInt call.");
+                throw new SqlException(agent_.logWriter_, 
+                    new MessageId(SQLState.INVALID_PARAM_USE_GETINT));
             }
             checkGetterPreconditions(parameterIndex);
             setWasNull(parameterIndex);
@@ -715,7 +724,8 @@
             super.checkForClosedStatement();
             parameterIndex = checkForEscapedCallWithResult(parameterIndex);
             if (parameterIndex == 0 && escapedProcedureCallWithResult_) {
-                throw new SqlException(agent_.logWriter_, "Invalid method call: parameter 1 is an integer OUT parameter returned by the stored procedure, use getInt call.");
+                throw new SqlException(agent_.logWriter_, 
+                    new MessageId(SQLState.INVALID_PARAM_USE_GETINT));
             }
             checkGetterPreconditions(parameterIndex);
             setWasNull(parameterIndex);
@@ -735,13 +745,15 @@
             super.checkForClosedStatement();
             parameterIndex = checkForEscapedCallWithResult(parameterIndex);
             if (parameterIndex == 0 && escapedProcedureCallWithResult_) {
-                throw new SqlException(agent_.logWriter_, "Invalid method call: parameter 1 is an integer OUT parameter returned by the stored procedure, use getInt call.");
+                throw new SqlException(agent_.logWriter_, 
+                    new MessageId(SQLState.INVALID_PARAM_USE_GETINT));                    
             }
             checkGetterPreconditions(parameterIndex);
             setWasNull(parameterIndex);
             java.sql.Array result = wasNullX() ? null : singletonRowData_.getArray(parameterIndex);
             if (true) {
-                throw new SqlException(agent_.logWriter_, "jdbc 2 method is not yet implemented");
+                throw new SqlException(agent_.logWriter_, 
+                    new MessageId(SQLState.JDBC2_METHOD_NOT_IMPLEMENTED));
             }
             if (agent_.loggingEnabled()) {
                 agent_.logWriter_.traceExit(this, "getArray", result);
@@ -758,13 +770,15 @@
             super.checkForClosedStatement();
             parameterIndex = checkForEscapedCallWithResult(parameterIndex);
             if (parameterIndex == 0 && escapedProcedureCallWithResult_) {
-                throw new SqlException(agent_.logWriter_, "Invalid method call: parameter 1 is an integer OUT parameter returned by the stored procedure, use getInt call.");
+                throw new SqlException(agent_.logWriter_, 
+                    new MessageId(SQLState.INVALID_PARAM_USE_GETINT));
             }
             checkGetterPreconditions(parameterIndex);
             setWasNull(parameterIndex);
             java.sql.Ref result = wasNullX() ? null : singletonRowData_.getRef(parameterIndex);
             if (true) {
-                throw new SqlException(agent_.logWriter_, "jdbc 2 method is not yet implemented");
+                throw new SqlException(agent_.logWriter_, 
+                    new MessageId(SQLState.JDBC2_METHOD_NOT_IMPLEMENTED));
             }
             if (agent_.loggingEnabled()) {
                 agent_.logWriter_.traceExit(this, "getRef", result);
@@ -809,7 +823,8 @@
             Object result;
             checkGetterPreconditions(parameterIndex);
             if (true) {
-                throw new SqlException(agent_.logWriter_, "jdbc 2 method is not yet implemented.");
+                throw new SqlException(agent_.logWriter_, 
+                    new MessageId(SQLState.JDBC2_METHOD_NOT_IMPLEMENTED));
             }
             if (agent_.loggingEnabled()) {
                 agent_.logWriter_.traceExit(this, "getObject", result);
@@ -825,7 +840,7 @@
             agent_.logWriter_.traceEntry(this, "registerOutParameter", parameterName, sqlType);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void registerOutParameter(String parameterName, int sqlType, int scale) throws SqlException {
@@ -833,7 +848,7 @@
             agent_.logWriter_.traceEntry(this, "registerOutParameter", parameterName, sqlType, scale);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void registerOutParameter(String parameterName, int sqlType, String typeName) throws SqlException {
@@ -841,7 +856,7 @@
             agent_.logWriter_.traceEntry(this, "registerOutParameter", parameterName, sqlType, typeName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public java.net.URL getURL(int parameterIndex) throws SqlException {
@@ -849,7 +864,7 @@
             agent_.logWriter_.traceEntry(this, "getURL", parameterIndex);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setURL(String parameterName, java.net.URL x) throws SqlException {
@@ -857,7 +872,7 @@
             agent_.logWriter_.traceEntry(this, "setURL", parameterName, x);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setNull(String parameterName, int sqlType) throws SqlException {
@@ -865,7 +880,7 @@
             agent_.logWriter_.traceEntry(this, "setNull", parameterName, sqlType);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setBoolean(String parameterName, boolean x) throws SqlException {
@@ -873,7 +888,7 @@
             agent_.logWriter_.traceEntry(this, "setBoolean", parameterName, x);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setByte(String parameterName, byte x) throws SqlException {
@@ -881,7 +896,7 @@
             agent_.logWriter_.traceEntry(this, "setByte", parameterName, x);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setShort(String parameterName, short x) throws SqlException {
@@ -889,7 +904,7 @@
             agent_.logWriter_.traceEntry(this, "setShort", parameterName, x);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setInt(String parameterName, int x) throws SqlException {
@@ -897,7 +912,7 @@
             agent_.logWriter_.traceEntry(this, "setInt", parameterName, x);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setLong(String parameterName, long x) throws SqlException {
@@ -905,7 +920,7 @@
             agent_.logWriter_.traceEntry(this, "setLong", parameterName, x);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setFloat(String parameterName, float x) throws SqlException {
@@ -913,7 +928,7 @@
             agent_.logWriter_.traceEntry(this, "setFloat", parameterName, x);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setDouble(String parameterName, double x) throws SqlException {
@@ -921,7 +936,7 @@
             agent_.logWriter_.traceEntry(this, "setDouble", parameterName, x);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setBigDecimal(String parameterName, java.math.BigDecimal x) throws SqlException {
@@ -929,7 +944,7 @@
             agent_.logWriter_.traceEntry(this, "setBigDecimal", parameterName, x);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setString(String parameterName, String x) throws SqlException {
@@ -937,7 +952,7 @@
             agent_.logWriter_.traceEntry(this, "setString", parameterName, x);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setBytes(String parameterName, byte x[]) throws SqlException {
@@ -945,7 +960,7 @@
             agent_.logWriter_.traceEntry(this, "setBytes", parameterName, x);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setDate(String parameterName, java.sql.Date x) throws SqlException {
@@ -953,7 +968,7 @@
             agent_.logWriter_.traceEntry(this, "setDate", parameterName, x);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setTime(String parameterName, java.sql.Time x) throws SqlException {
@@ -961,7 +976,7 @@
             agent_.logWriter_.traceEntry(this, "setTime", parameterName, x);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setTimestamp(String parameterName, java.sql.Timestamp x) throws SqlException {
@@ -969,7 +984,7 @@
             agent_.logWriter_.traceEntry(this, "setTimestamp", parameterName, x);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setAsciiStream(String parameterName, java.io.InputStream x, int length) throws SqlException {
@@ -977,7 +992,7 @@
             agent_.logWriter_.traceEntry(this, "setAsciiStream", parameterName, x, length);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setBinaryStream(String parameterName, java.io.InputStream x, int length) throws SqlException {
@@ -985,7 +1000,7 @@
             agent_.logWriter_.traceEntry(this, "setBinaryStream", parameterName, x, length);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SqlException {
@@ -993,7 +1008,7 @@
             agent_.logWriter_.traceEntry(this, "setObject", parameterName, x, targetSqlType, scale);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setObject(String parameterName, Object x, int targetSqlType) throws SqlException {
@@ -1001,7 +1016,7 @@
             agent_.logWriter_.traceEntry(this, "setObject", parameterName, x, targetSqlType);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setObject(String parameterName, Object x) throws SqlException {
@@ -1009,7 +1024,7 @@
             agent_.logWriter_.traceEntry(this, "setObject", parameterName, x);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setCharacterStream(String parameterName, java.io.Reader reader, int length) throws SqlException {
@@ -1017,7 +1032,7 @@
             agent_.logWriter_.traceEntry(this, "setCharacterStream", parameterName, reader, length);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setDate(String parameterName, java.sql.Date x, java.util.Calendar calendar) throws SqlException {
@@ -1025,7 +1040,7 @@
             agent_.logWriter_.traceEntry(this, "setDate", parameterName, x, calendar);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setTime(String parameterName, java.sql.Time x, java.util.Calendar calendar) throws SqlException {
@@ -1033,7 +1048,7 @@
             agent_.logWriter_.traceEntry(this, "setTime", parameterName, x, calendar);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setTimestamp(String parameterName, java.sql.Timestamp x, java.util.Calendar calendar) throws SqlException {
@@ -1041,7 +1056,7 @@
             agent_.logWriter_.traceEntry(this, "setTimestamp", parameterName, x, calendar);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public void setNull(String parameterName, int sqlType, String typeName) throws SqlException {
@@ -1049,7 +1064,7 @@
             agent_.logWriter_.traceEntry(this, "setNull", parameterName, sqlType, typeName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public String getString(String parameterName) throws SqlException {
@@ -1057,7 +1072,7 @@
             agent_.logWriter_.traceEntry(this, "getString", parameterName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public boolean getBoolean(String parameterName) throws SqlException {
@@ -1065,7 +1080,7 @@
             agent_.logWriter_.traceEntry(this, "getBoolean", parameterName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public byte getByte(String parameterName) throws SqlException {
@@ -1073,7 +1088,7 @@
             agent_.logWriter_.traceEntry(this, "getByte", parameterName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public short getShort(String parameterName) throws SqlException {
@@ -1081,7 +1096,7 @@
             agent_.logWriter_.traceEntry(this, "getShort", parameterName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public int getInt(String parameterName) throws SqlException {
@@ -1089,7 +1104,7 @@
             agent_.logWriter_.traceEntry(this, "getInt", parameterName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public long getLong(String parameterName) throws SqlException {
@@ -1097,7 +1112,7 @@
             agent_.logWriter_.traceEntry(this, "getLong", parameterName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public float getFloat(String parameterName) throws SqlException {
@@ -1105,7 +1120,7 @@
             agent_.logWriter_.traceEntry(this, "getFloat", parameterName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public double getDouble(String parameterName) throws SqlException {
@@ -1113,7 +1128,7 @@
             agent_.logWriter_.traceEntry(this, "getDouble", parameterName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public byte[] getBytes(String parameterName) throws SqlException {
@@ -1121,7 +1136,7 @@
             agent_.logWriter_.traceEntry(this, "getBytes", parameterName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public java.sql.Date getDate(String parameterName) throws SqlException {
@@ -1129,7 +1144,7 @@
             agent_.logWriter_.traceEntry(this, "getDate", parameterName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public java.sql.Time getTime(String parameterName) throws SqlException {
@@ -1137,7 +1152,7 @@
             agent_.logWriter_.traceEntry(this, "getTime", parameterName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public java.sql.Timestamp getTimestamp(String parameterName) throws SqlException {
@@ -1145,7 +1160,7 @@
             agent_.logWriter_.traceEntry(this, "getTimestamp", parameterName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public Object getObject(String parameterName) throws SqlException {
@@ -1153,7 +1168,7 @@
             agent_.logWriter_.traceEntry(this, "getObject", parameterName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public java.math.BigDecimal getBigDecimal(String parameterName) throws SqlException {
@@ -1161,7 +1176,7 @@
             agent_.logWriter_.traceEntry(this, "getBigDecimal", parameterName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public Object getObject(String parameterName, java.util.Map map) throws SqlException {
@@ -1169,7 +1184,7 @@
             agent_.logWriter_.traceEntry(this, "getObject", parameterName, map);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public java.sql.Ref getRef(String parameterName) throws SqlException {
@@ -1177,7 +1192,7 @@
             agent_.logWriter_.traceEntry(this, "getRef", parameterName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public java.sql.Blob getBlob(String parameterName) throws SqlException {
@@ -1185,7 +1200,7 @@
             agent_.logWriter_.traceEntry(this, "getBlob", parameterName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public java.sql.Clob getClob(String parameterName) throws SqlException {
@@ -1193,7 +1208,7 @@
             agent_.logWriter_.traceEntry(this, "getClob", parameterName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public java.sql.Array getArray(String parameterName) throws SqlException {
@@ -1201,7 +1216,7 @@
             agent_.logWriter_.traceEntry(this, "getArray", parameterName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public java.sql.Date getDate(String parameterName, java.util.Calendar calendar) throws SqlException {
@@ -1209,7 +1224,7 @@
             agent_.logWriter_.traceEntry(this, "getDate", parameterName, calendar);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public java.sql.Time getTime(String parameterName, java.util.Calendar calendar) throws SqlException {
@@ -1217,7 +1232,7 @@
             agent_.logWriter_.traceEntry(this, "getTime", parameterName, calendar);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public java.sql.Timestamp getTimestamp(String parameterName, java.util.Calendar calendar) throws SqlException {
@@ -1225,7 +1240,7 @@
             agent_.logWriter_.traceEntry(this, "getTimestamp", parameterName, calendar);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     public java.net.URL getURL(String parameterName) throws SqlException {
@@ -1233,7 +1248,7 @@
             agent_.logWriter_.traceEntry(this, "getURL", parameterName);
         }
         super.checkForClosedStatement();
-        throw new SqlException(agent_.logWriter_, "JDBC 3 method called - not yet supported");
+        throw jdbc3MethodNotSupported();
     }
 
     //----------------------------helper methods----------------------------------
@@ -1248,7 +1263,8 @@
     private int checkForEscapedCallWithResult(int parameterIndex, int jdbcType) throws SqlException {
         if (escapedProcedureCallWithResult_) {
             if (parameterIndex == 1 && jdbcType != java.sql.Types.INTEGER) {
-                throw new SqlException(agent_.logWriter_, "Parameter 1 is the return caluse of the stored procedure call, it can only be registered as an integer type");
+                throw new SqlException(agent_.logWriter_, 
+                    new MessageId(SQLState.RETURN_PARAM_MUST_BE_INT));
             } else {
                 parameterIndex--;
             }
@@ -1263,8 +1279,9 @@
 
     private void checkForValidOutParameter(int parameterIndex) throws SqlException {
         if (parameterMetaData_ == null || parameterMetaData_.sqlxParmmode_[parameterIndex - 1] < java.sql.ParameterMetaData.parameterModeInOut) {
-            throw new SqlException(agent_.logWriter_, "Invalid argument: parameter index " + parameterIndex +
-                    " is not an OUT or INOUT parameter.");
+            throw new SqlException(agent_.logWriter_, 
+                new MessageId(SQLState.PARAM_NOT_OUT_OR_INOUT), 
+                new Integer(parameterIndex));
         }
     }
 
@@ -1274,6 +1291,12 @@
         } else {
             wasNull_ = singletonRowData_.isNull_[parameterIndex - 1] ? WAS_NULL : WAS_NOT_NULL;
         }
+    }
+    
+    private SqlException jdbc3MethodNotSupported()
+    {
+        return new SqlException(agent_.logWriter_, 
+            new MessageId(SQLState.JDBC3_METHOD_NOT_SUPPORTED));
     }
 }
 

Added: db/derby/code/trunk/java/client/org/apache/derby/client/am/MessageId.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/MessageId.java?rev=370815&view=auto
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/MessageId.java (added)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/MessageId.java Fri Jan 20 06:25:53 2006
@@ -0,0 +1,39 @@
+/*
+   Derby - Class org.apache.derby.client.am.MessageId
+ 
+   Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ 
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+ 
+      http://www.apache.org/licenses/LICENSE-2.0
+ 
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ 
+ */
+package org.apache.derby.client.am;
+
+/**
+ * A very simple wrapper around a message id.  This is needed so that
+ * the new constructors for SqlException using message ids don't conflict
+ * with the old constructors.  
+ *
+ * Once all messages have been internationalized, we could conceivably
+ * get rid of this class.
+ */
+public class MessageId
+{
+    public String msgid;
+    
+    /** Creates a new instance of MessageId */
+    public MessageId(String msgid)
+    {
+        this.msgid = msgid;
+    }
+    
+}

Propchange: db/derby/code/trunk/java/client/org/apache/derby/client/am/MessageId.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=370815&r1=370814&r2=370815&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 Fri Jan 20 06:25:53 2006
@@ -20,7 +20,12 @@
 
 package org.apache.derby.client.am;
 
+import java.sql.SQLException;
+
 import org.apache.derby.client.resources.ResourceKeys;
+import org.apache.derby.shared.common.info.JVMInfo;
+import org.apache.derby.shared.common.i18n.MessageUtil;
+import org.apache.derby.shared.common.error.ExceptionUtil;
 
 
 // The signature of the stored procedure SQLCAMessage I have come out so far is as follows:
@@ -49,146 +54,163 @@
 // 4. What if the invocation of stored procedure failed (due to, eg, connection dropping)? In this case, we probably need to return some client-side message.
 
 public class SqlException extends java.sql.SQLException implements Diagnosable {
+    protected static final int DEFAULT_ERRCODE = 99999;
     java.lang.Throwable throwable_ = null;
     protected Sqlca sqlca_ = null; // for engine generated errors only
+    protected String message_ = null;
     private String batchPositionLabel_; // for batched exceptions only
+    
+    public static String CLIENT_MESSAGE_RESOURCE_NAME =
+        "org.apache.derby.loc.client-messages";
+    
+    // The message utility instance we use to find messages
+    // It's primed with the name of the client message bundle so that
+    // it knows to look there if the message isn't found in the
+    // shared message bundle.
+    private static MessageUtil msgutil_ = 
+        new MessageUtil(CLIENT_MESSAGE_RESOURCE_NAME);
 
+    
     //-----------------constructors-----------------------------------------------
-
-    public SqlException(LogWriter logWriter, ErrorKey errorKey) {
-        super(ResourceUtilities.getResource(ResourceKeys.driverOriginationIndicator) +
-                ResourceUtilities.getResource(errorKey.getResourceKey()),
-                errorKey.getSQLState(),
-                errorKey.getErrorCode());
-        if (logWriter != null) {
-            logWriter.traceDiagnosable(this);
-        }
+    // New constructors that support internationalized messages
+    // The message id is wrapped inside a class so that we can distinguish
+    // between the signatures of the new constructors and the old constructors
+    public SqlException(LogWriter logwriter, 
+        MessageId msgid, Object[] args, Throwable cause)
+    {
+        this(
+            logwriter,
+            msgutil_.getCompleteMessage(
+                msgid.msgid,
+                args),
+            ExceptionUtil.getSQLStateFromIdentifier(msgid.msgid),
+            ExceptionUtil.getSeverityFromIdentifier(msgid.msgid));
     }
-
-    public SqlException(LogWriter logWriter, ErrorKey errorKey, Object[] args) {
-        super(ResourceUtilities.getResource(ResourceKeys.driverOriginationIndicator) +
-                ResourceUtilities.getResource(errorKey.getResourceKey(), args),
-                errorKey.getSQLState(),
-                errorKey.getErrorCode());
-        if (logWriter != null) {
+    
+    public SqlException(LogWriter logwriter, MessageId msgid, Object[] args)
+    {
+        this(logwriter, msgid, args, null);
+    }
+    
+    public SqlException (LogWriter logwriter, MessageId msgid)
+    {
+        this(logwriter, msgid, null);
+    }
+    
+    public SqlException(LogWriter logwriter, MessageId msgid, Object arg1)
+    {
+        this(logwriter, msgid, new Object[] { arg1 });
+    }
+    
+    public SqlException(LogWriter logwriter,
+        MessageId msgid, Object arg1, Object arg2)
+    {
+        this(logwriter, msgid, new Object[] { arg1, arg2 });
+    }
+    
+    public SqlException(LogWriter logwriter,
+        MessageId msgid, Object arg1, Object arg2, Object arg3)
+    {
+        this(logwriter, msgid, new Object[] { arg1, arg2, arg3 });
+    }
+    
+    public SqlException(LogWriter logWriter, Sqlca sqlca) {
+        this.sqlca_ = sqlca;
+        if ( logWriter != null )
+        {
             logWriter.traceDiagnosable(this);
         }
     }
-
-    public SqlException(LogWriter logWriter, ErrorKey errorKey, Object arg) {
-        this(logWriter, errorKey, new Object[]{arg});
+    
+    // Once all messages are internationalized, these methods should become
+    // private
+    public SqlException(LogWriter logWriter, String reason, String sqlState,
+        int errorCode)
+    {
+        this(logWriter, null, reason, sqlState, errorCode);
     }
 
-    public SqlException(LogWriter logWriter, Sqlca sqlca) {
-        super();
-        sqlca_ = sqlca;
+    private SqlException(LogWriter logWriter, java.lang.Throwable throwable, 
+        String reason, String sqlState, int errorCode ) {
+        super(reason, sqlState, errorCode);
+        message_ = reason;
+        throwable_ = throwable;
+
+        setCause();
+        
         if (logWriter != null) {
             logWriter.traceDiagnosable(this);
         }
+        
     }
-
-    // Temporary constructor until all error keys are defined.
+        
+    protected void setCause()
+    {
+        // Store the throwable correctly depending upon its class
+        // and whether initCause() is available
+        if (throwable_ != null  )
+        {
+            if ( throwable_ instanceof SQLException )
+            {
+                setNextException((SQLException)throwable_);
+            }
+            else if ( JVMInfo.JDK_ID >= JVMInfo.J2SE_14 )
+            {
+    			initCause(throwable_);
+            }
+            else
+            {
+                message_ = message_ + " Caused by exception " + 
+                    throwable_.getClass() + ": " + throwable_.getMessage();
+
+            }
+        }
+    }
+        
+    // Constructors for backward-compatibility while we're internationalizng
+    // all the messages
     public SqlException(LogWriter logWriter) {
-        super(null, null, -99999);
         if (logWriter != null) {
             logWriter.traceDiagnosable(this);
         }
     }
 
-    /*
-    // Temporary constructor until all error keys are defined.
-    public SQLException (LogWriter logWriter, java.lang.Throwable throwable)
-    {
-      super ();
-      throwable_ = throwable;
-      if (logWriter != null) logWriter.traceDiagnosable (this);
-    }
-    */
-
-    // Temporary constructor until all error keys are defined.
     public SqlException(LogWriter logWriter, String reason) {
-        super(reason, null, -99999);
-        if (logWriter != null) {
-            logWriter.traceDiagnosable(this);
-        }
+        this(logWriter, reason, null, DEFAULT_ERRCODE);
     }
 
-    // Temporary constructor until all error keys are defined.
     public SqlException(LogWriter logWriter, java.lang.Throwable throwable, String reason) {
-        super(reason, null, -99999);
-        throwable_ = throwable;
-        if (logWriter != null) {
-            logWriter.traceDiagnosable(this);
-        }
+        this(logWriter, throwable, reason, null, DEFAULT_ERRCODE);
     }
 
-    // Temporary constructor until all error keys are defined.
     public SqlException(LogWriter logWriter, java.lang.Throwable throwable, String reason, SqlState sqlstate) {
-        super(reason, sqlstate.getState(), -99999);
-        throwable_ = throwable;
-        if (logWriter != null) {
-            logWriter.traceDiagnosable(this);
-        }
+        this(logWriter, throwable, reason, sqlstate.getState(), DEFAULT_ERRCODE);
     }
 
-    // Temporary constructor until all error keys are defined, for subsystem use only.
     public SqlException(LogWriter logWriter, java.lang.Throwable throwable, String reason, String sqlstate) {
-        super(reason, sqlstate, -99999);
-        throwable_ = throwable;
-        if (logWriter != null) {
-            logWriter.traceDiagnosable(this);
-        }
+        this(logWriter, throwable, reason, sqlstate, DEFAULT_ERRCODE);
     }
 
-    // Temporary constructor until all error keys are defined.
     public SqlException(LogWriter logWriter, String reason, SqlState sqlState) {
-        super(reason, sqlState.getState(), -99999);
-        if (logWriter != null) {
-            logWriter.traceDiagnosable(this);
-        }
+        this(logWriter, reason, sqlState.getState(), DEFAULT_ERRCODE);
     }
 
-    // Temporary constructor until all error keys are defined, for subsystem use only.
     public SqlException(LogWriter logWriter, String reason, String sqlState) {
-        super(reason, sqlState, -99999);
-        if (logWriter != null) {
-            logWriter.traceDiagnosable(this);
-        }
+        this(logWriter, reason, sqlState, DEFAULT_ERRCODE);
     }
 
-    // Temporary constructor until all error keys are defined.
     public SqlException(LogWriter logWriter, String reason, SqlState sqlState, SqlCode errorCode) {
-        super(reason, (sqlState == null) ? null : sqlState.getState(), errorCode.getCode());
-        if (logWriter != null) {
-            logWriter.traceDiagnosable(this);
-        }
+        this(logWriter, reason, sqlState.getState(), errorCode.getCode());
     }
+    
 
-    // Temporary constructor until all error keys are defined, for subsystem use only.
-    public SqlException(LogWriter logWriter, String reason, String sqlState, int errorCode) {
-        super(reason, sqlState, errorCode);
-        if (logWriter != null) {
-            logWriter.traceDiagnosable(this);
-        }
-    }
-
-    // Temporary constructor until all error keys are defined.
     public SqlException(LogWriter logWriter, java.lang.Throwable throwable, String reason, SqlState sqlState, SqlCode errorCode) {
-        super(reason, sqlState.getState(), errorCode.getCode());
-        throwable_ = throwable;
-        if (logWriter != null) {
-            logWriter.traceDiagnosable(this);
-        }
+        this(logWriter, throwable, reason, sqlState.getState(), 
+            errorCode.getCode());
     }
 
-    // Temporary constructor until all error keys are defined, for subsystem use only.
-    public SqlException(LogWriter logWriter, java.lang.Throwable throwable, String reason, String sqlState, int errorCode) {
-        super(reason, sqlState, errorCode);
-        throwable_ = throwable;
-        if (logWriter != null) {
-            logWriter.traceDiagnosable(this);
-        }
-    }
+    //--- End backward-compatibility constructors ----------------------
+    
 
     // Label an exception element in a batched update exception chain.
     // This text will be prepended onto the exceptions message text dynamically
@@ -207,19 +229,15 @@
     }
 
     public String getMessage() {
-        String message;
-
-        if (sqlca_ == null) {
-            message = super.getMessage();
-        } else {
-            message = ((Sqlca) sqlca_).getJDBCMessage();
+        if (sqlca_ != null) {
+            message_ = ((Sqlca) sqlca_).getJDBCMessage();
         }
 
         if (batchPositionLabel_ == null) {
-            return message;
+            return message_;
         }
 
-        return batchPositionLabel_ + message;
+        return batchPositionLabel_ + message_;
     }
 
     public String getSQLState() {
@@ -241,7 +259,7 @@
     public void printTrace(java.io.PrintWriter printWriter, String header) {
         ExceptionFormatter.printTrace(this, printWriter, header);
     }
-
+    
     // Return a single SQLException without the "next" pointing to another SQLException.
     // Because the "next" is a private field in java.sql.SQLException,
     // we have to create a new SqlException in order to break the chain with "next" as null.

Added: db/derby/code/trunk/java/client/org/apache/derby/loc/client-messages.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/loc/client-messages.properties?rev=370815&view=auto
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/loc/client-messages.properties (added)
+++ db/derby/code/trunk/java/client/org/apache/derby/loc/client-messages.properties Fri Jan 20 06:25:53 2006
@@ -0,0 +1,7 @@
+!
+!
+!
+! ALL ENGLISH MESSAGES ARE IN client-messages_en.properties
+!
+! DO NOT ADD ANYTHING TO THIS FILE
+!

Propchange: db/derby/code/trunk/java/client/org/apache/derby/loc/client-messages.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/client/org/apache/derby/loc/client-messages_en.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/loc/client-messages_en.properties?rev=370815&view=auto
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/loc/client-messages_en.properties (added)
+++ db/derby/code/trunk/java/client/org/apache/derby/loc/client-messages_en.properties Fri Jan 20 06:25:53 2006
@@ -0,0 +1,60 @@
+#
+#   Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#
+# This file contains messages that specific to the Derby client.
+#
+# You can use the message ids (or add message ids)
+# defined in org.apache.derby.sahred.common.reference.SQLState.java in 
+# network client code.  
+#
+# BEFORE YOU ADD A MESSAGE HERE, make sure a similar message doesn't already
+# exist in java/engine/org/apache/derby/loc/messages_en.properties.  If it
+# does, you can reuse the matching message id and share this message across
+# client and engine.  
+#
+# You do NOT need to copy the message from the engine messages_en.properties 
+# to here.  This is done at build time.  If the message id starts with "XJ" 
+# there is nothing you need to do, the copy is done automatically.  
+#
+# For any message ids that DO NOT START with "XJ" YOU NEED TO DO A LITTLE WORK.  
+# In java/build/org/apache/derbyBuild/splitmessages.java, you need to add 
+# the message id to clientMessageIds in the static method initClientMessageIds().  
+# If you do not do this YOUR MESSAGE WILL NOT BE COPIED and a default message 
+# will be used.
+#
+XN001.C=getConnection() is not valid on a closed PooledConnection.
+XN003.S=Blob offset ''{0}'' is either less than zero or is too large for the\
+ current blob.
+XN004.S=Invalid operation: wasNull() called with no data retrieved.
+XN005.S=Invalid method call: parameter 1 is an integer OUT parameter returned\
+ by the stored procedure, use getInt call.
+XN006.S=Invalid parameter: calendar is null.
+XN007.S=jdbc 2 method is not yet implemented.
+XN008.S=JDBC 3 method called - not yet supported
+XN009.S=Invalid argument: parameter index {0} is not an OUT or INOUT parameter.
+XN010.S=Parameter 1 is the return clause of the stored procedure call. It can\
+ only be registered as an integer type.
+
+
+
+#  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+#
+#
+#  DO NOT TRANSLATE MESSAGES OR TEXT BELOW THIS LINE
+#
+#
+# ----------------------------------------------------------------------------------------------------------
+
+

Propchange: db/derby/code/trunk/java/client/org/apache/derby/loc/client-messages_en.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/ExceptionSeverity.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/ExceptionSeverity.java?rev=370815&r1=370814&r2=370815&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/ExceptionSeverity.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/ExceptionSeverity.java Fri Jan 20 06:25:53 2006
@@ -21,52 +21,13 @@
 package org.apache.derby.iapi.error;
 
 /**
- * Severity constants for SQLExceptions.
- * 
- * These constants are used in the ErrorCode available on a SQLException
- * to provide information about the severity of the error.
+ * This is a refactoring wrapper around the common ExceptionSeverity class
+ * and may be removed at some point in the future.
  *
- * @see java.sql.SQLException
+ * @see org.apache.derby.common.error.ExceptionSeverity
  */
-public interface ExceptionSeverity
+public interface ExceptionSeverity 
+    extends org.apache.derby.shared.common.error.ExceptionSeverity
 {
-	/*
-	 * Use NO_APPLICABLE_SEVERITY for internal errors and unit
-	 * tests that don't need to report or worry about severities.
-	 */
-	/**
-	 * NO_APPLICABLE_SEVERITY occurs only when the system was
-	 * unable to determine the severity.
-	 */
-	public static final int NO_APPLICABLE_SEVERITY = 0;
-	/**
-	 * WARNING_SEVERITY is associated with SQLWarnings.
-	 */
-	public static final int WARNING_SEVERITY = 10000;
-	/**
-	 * STATEMENT_SEVERITY is associated with errors which
-	 * cause only the current statement to be aborted.
-	 */
-	public static final int STATEMENT_SEVERITY = 20000;
-	/**
-	 * TRANSACTION_SEVERITY is associated with those errors which
-	 * cause the current transaction to be aborted.
-	 */
-	public static final int TRANSACTION_SEVERITY = 30000;
-	/**
-	 * SESSION_SEVERITY is associated with errors which
-	 * cause the current connection to be closed.
-	 */
-	public static final int SESSION_SEVERITY = 40000;
-	/**
-	 * DATABASE_SEVERITY is associated with errors which
-	 * cause the current database to be closed.
-	 */
-	public static final int DATABASE_SEVERITY = 45000;
-	/**
-	 * SYSTEM_SEVERITY is associated with internal errors which
-	 * cause the system to shut down.
-	 */
-	public static final int SYSTEM_SEVERITY = 50000;
 }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/build.xml
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/loc/build.xml?rev=370815&r1=370814&r2=370815&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/build.xml (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/build.xml Fri Jan 20 06:25:53 2006
@@ -72,6 +72,7 @@
           failonerror="true">
       <arg value="${loc.dir}"/> 
       <arg value="${split.properties}"/>
+      <arg value="${derby.client.dir}/loc"/>
     </java>
     <touch file="${split.donefile}"/>
   </target>

Added: db/derby/code/trunk/java/shared/build.xml
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/shared/build.xml?rev=370815&view=auto
==============================================================================
--- db/derby/code/trunk/java/shared/build.xml (added)
+++ db/derby/code/trunk/java/shared/build.xml Fri Jan 20 06:25:53 2006
@@ -0,0 +1,61 @@
+<?xml version="1.0"?>
+<!-- ==================================================================== -->
+<!--                       Derby Shared Classes build file                -->
+<!-- ==================================================================== -->
+<project default="shared" basedir="../..">
+
+<!-- ==================================================================== -->
+<!--                           Set properties                             -->
+<!-- ==================================================================== -->
+
+
+  <!-- User settings -->
+  <property file="${user.home}/ant.properties"/>
+
+  <!-- Set property lib dir -->
+  <property name="properties.dir" value="tools/ant/properties"/>
+
+  <!-- Significant dirs -->
+  <property file="${properties.dir}/dirs.properties"/>
+
+  <!-- Compiler settings -->
+  <property file="${properties.dir}/defaultcompiler.properties"/>
+  <property file="${properties.dir}/${build.compiler}.properties"/>
+
+
+  <!-- Compile-time classpath properties files -->
+  <property file="${properties.dir}/extrapath.properties"/>
+  <property file="${properties.dir}/compilepath.properties"/>
+
+  <!-- Release and Version info -->
+  <property file="${properties.dir}/release.properties"/>
+  
+
+<!-- Targets -->
+
+<!-- compile classes  -->
+  <target name="compile">
+    <javac
+      bootclasspath="${empty}"
+      nowarn="on"
+      debug="${debug}"
+      depend="${depend}"
+      deprecation="${deprecation}"
+      optimize="${optimize}"
+      proceed="${proceed}"
+      verbose="${verbose}"
+      srcdir="${derby.shared.src.dir}"
+      includes="org/apache/derby/shared/**"
+      destdir="${out.dir}">
+      <classpath>
+          <pathelement path="${jce1_2_1}"/>
+          <pathelement path="${java14compile.classpath}"/>
+      </classpath>
+    </javac>
+</target>
+  
+
+<!-- default target  -->
+  <target name="shared" depends="compile"/>
+</project>
+

Propchange: db/derby/code/trunk/java/shared/build.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/error/ExceptionSeverity.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/error/ExceptionSeverity.java?rev=370815&view=auto
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/error/ExceptionSeverity.java (added)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/error/ExceptionSeverity.java Fri Jan 20 06:25:53 2006
@@ -0,0 +1,73 @@
+/*
+
+   Derby - Class org.apache.derby.iapi.error.ExceptionSeverity
+
+   Copyright 1997, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derby.shared.common.error;
+
+/**
+ * Severity constants for SQLExceptions.
+ * 
+ * These constants are used in the ErrorCode available on a SQLException
+ * to provide information about the severity of the error.
+ *
+ * @see java.sql.SQLException
+ */
+public interface ExceptionSeverity
+{
+	/*
+	 * Use NO_APPLICABLE_SEVERITY for internal errors and unit
+	 * tests that don't need to report or worry about severities.
+	 */
+	/**
+	 * NO_APPLICABLE_SEVERITY occurs only when the system was
+	 * unable to determine the severity.
+	 */
+	public static final int NO_APPLICABLE_SEVERITY = 0;
+	/**
+	 * WARNING_SEVERITY is associated with SQLWarnings.
+	 */
+	public static final int WARNING_SEVERITY = 10000;
+	/**
+	 * STATEMENT_SEVERITY is associated with errors which
+	 * cause only the current statement to be aborted.
+	 */
+	public static final int STATEMENT_SEVERITY = 20000;
+	/**
+	 * TRANSACTION_SEVERITY is associated with those errors which
+	 * cause the current transaction to be aborted.
+	 */
+	public static final int TRANSACTION_SEVERITY = 30000;
+	/**
+	 * SESSION_SEVERITY is associated with errors which
+	 * cause the current connection to be closed.
+	 */
+	public static final int SESSION_SEVERITY = 40000;
+	/**
+	 * DATABASE_SEVERITY is associated with errors which
+	 * cause the current database to be closed.
+	 */
+	public static final int DATABASE_SEVERITY = 45000;
+	/**
+	 * SYSTEM_SEVERITY is associated with internal errors which
+	 * cause the system to shut down.
+	 */
+	public static final int SYSTEM_SEVERITY = 50000;
+}
+
+

Propchange: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/error/ExceptionSeverity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/error/ExceptionUtil.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/error/ExceptionUtil.java?rev=370815&view=auto
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/error/ExceptionUtil.java (added)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/error/ExceptionUtil.java Fri Jan 20 06:25:53 2006
@@ -0,0 +1,111 @@
+/*
+   Derby - Class org.apache.derby.common.error.ExceptionUtil
+ 
+   Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ 
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+ 
+      http://www.apache.org/licenses/LICENSE-2.0
+ 
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ 
+ */
+package org.apache.derby.shared.common.error;
+
+import org.apache.derby.shared.common.error.ExceptionSeverity;
+
+/**
+ * This class provides utility routines for exceptions 
+ */
+public class ExceptionUtil
+{
+   	/**
+	 *  Convert a message identifer from 
+     *  org.apache.derby.shared.common.reference.SQLState to
+	 *  a SQLState five character string.
+     *
+	 *	@param messageID - the sql state id of the message from cloudscape
+	 *	@return String 	 - the 5 character code of the SQLState ID to returned to the user 
+	*/
+	public static String getSQLStateFromIdentifier(String messageID) {
+
+		if (messageID.length() == 5)
+			return messageID;
+		return messageID.substring(0, 5);
+	}
+    
+   	/**
+	* Get the severity given a message identifier from SQLState.
+	*/
+	public static int getSeverityFromIdentifier(String messageID) {
+
+		int lseverity = ExceptionSeverity.NO_APPLICABLE_SEVERITY;
+
+		switch (messageID.length()) {
+		case 5:
+			switch (messageID.charAt(0)) {
+			case '0':
+				switch (messageID.charAt(1)) {
+				case '1':
+					lseverity = ExceptionSeverity.WARNING_SEVERITY;
+					break;
+				case 'A':
+				case '7':
+					lseverity = ExceptionSeverity.STATEMENT_SEVERITY;
+					break;
+				case '8':
+					lseverity = ExceptionSeverity.SESSION_SEVERITY;
+					break;
+				}
+				break;	
+			case '2':
+			case '3':
+				lseverity = ExceptionSeverity.STATEMENT_SEVERITY;
+				break;
+			case '4':
+				switch (messageID.charAt(1)) {
+				case '0':
+					lseverity = ExceptionSeverity.TRANSACTION_SEVERITY;
+					break;
+				case '2':
+					lseverity = ExceptionSeverity.STATEMENT_SEVERITY;
+					break;
+				}
+				break;	
+			}
+			break;
+
+		default:
+			switch (messageID.charAt(6)) {
+			case 'M':
+				lseverity = ExceptionSeverity.SYSTEM_SEVERITY;
+				break;
+			case 'D':
+				lseverity = ExceptionSeverity.DATABASE_SEVERITY;
+				break;
+			case 'C':
+				lseverity = ExceptionSeverity.SESSION_SEVERITY;
+				break;
+			case 'T':
+				lseverity = ExceptionSeverity.TRANSACTION_SEVERITY;
+				break;
+			case 'S':
+				lseverity = ExceptionSeverity.STATEMENT_SEVERITY;
+				break;
+			case 'U':
+				lseverity = ExceptionSeverity.NO_APPLICABLE_SEVERITY;
+				break;
+			}
+			break;
+		}
+
+		return lseverity;
+	}
+
+}

Propchange: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/error/ExceptionUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message