db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1496449 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc: ConnectionChild.java EmbedConnection.java
Date Tue, 25 Jun 2013 12:36:30 GMT
Author: kahatlen
Date: Tue Jun 25 12:36:30 2013
New Revision: 1496449

URL: http://svn.apache.org/r1496449
Log:
DERBY-6262: Simplify message-generating methods using varargs

Use varargs in EmbedConnection.newSQLException() and
ConnectionChild.newSQLException().

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ConnectionChild.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ConnectionChild.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ConnectionChild.java?rev=1496449&r1=1496448&r2=1496449&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ConnectionChild.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ConnectionChild.java Tue Jun
25 12:36:30 2013
@@ -145,15 +145,9 @@ abstract class ConnectionChild {
 		return cal;
 	}
 
-	SQLException newSQLException(String messageId) {
-		return localConn.newSQLException(messageId);
-	}
-	SQLException newSQLException(String messageId, Object arg1) {
-		return localConn.newSQLException(messageId, arg1);
-	}
-	SQLException newSQLException(String messageId, Object arg1, Object arg2) {
-		return localConn.newSQLException(messageId, arg1, arg2);
-	}
+    static SQLException newSQLException(String messageId, Object... args) {
+        return EmbedConnection.newSQLException(messageId, args);
+    }
 
     protected static void restoreIntrFlagIfSeen(
         boolean pushStack, EmbedConnection ec) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java?rev=1496449&r1=1496448&r2=1496449&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java Tue Jun
25 12:36:30 2013
@@ -137,7 +137,7 @@ public class EmbedConnection implements 
      * like the VM dying could occur. Simpler just to throw a static.
      */
     public static final SQLException NO_MEM =
-        Util.generateCsSQLException(SQLState.LOGIN_FAILED, "java.lang.OutOfMemoryError");
+        newSQLException(SQLState.LOGIN_FAILED, "java.lang.OutOfMemoryError");
     
     /**
      * Low memory state object for connection requests.
@@ -2311,8 +2311,8 @@ public class EmbedConnection implements 
     public final void setTypeMap(java.util.Map map) throws SQLException {
         checkIfClosed();
         if( map == null)
-            throw Util.generateCsSQLException(SQLState.INVALID_API_PARAMETER,map,"map",
-                                              "java.sql.Connection.setTypeMap");
+            throw newSQLException(SQLState.INVALID_API_PARAMETER, map, "map",
+                                  "java.sql.Connection.setTypeMap");
         if(!(map.isEmpty()))
             throw Util.notImplemented();
     }
@@ -2704,15 +2704,15 @@ public class EmbedConnection implements 
             
             factory.checkSystemPrivileges(user, dp);
         } catch (AccessControlException ace) {
-            throw Util.generateCsSQLException(
+            throw newSQLException(
                     SQLState.AUTH_DATABASE_CREATE_MISSING_PERMISSION,
                     user, dbname, ace);
         } catch (IOException ioe) {
-            throw Util.generateCsSQLException(
+            throw newSQLException(
                     SQLState.AUTH_DATABASE_CREATE_EXCEPTION,
                     dbname, (Object)ioe); // overloaded method
         } catch (Exception e) {
-            throw Util.generateCsSQLException(
+            throw newSQLException(
                     SQLState.AUTH_DATABASE_CREATE_EXCEPTION,
                     dbname, (Object)e); // overloaded method
         }
@@ -3150,8 +3150,8 @@ public class EmbedConnection implements 
 			case TransactionControl.UNSPECIFIED_ISOLATION_LEVEL:
 				break;
 			default:
-				throw Util.generateCsSQLException(
-															   SQLState.UNIMPLEMENTED_ISOLATION_LEVEL, new Integer(level));
+                throw newSQLException(
+                        SQLState.UNIMPLEMENTED_ISOLATION_LEVEL, level);
 		}
 		
 		synchronized(getConnectionSynchronization())
@@ -3183,18 +3183,9 @@ public class EmbedConnection implements 
 		}
 	}
 
-	protected static SQLException newSQLException(String messageId) {
-		return Util.generateCsSQLException(messageId);
-	}
-	protected static SQLException newSQLException(String messageId, Object arg1) {
-		return Util.generateCsSQLException(messageId, arg1);
-	}
-	protected static SQLException newSQLException(String messageId, Object arg1, Object arg2)
{
-		return Util.generateCsSQLException(messageId, arg1, arg2);
-	}
-	protected static SQLException newSQLException(String messageId, Object arg1, Object arg2,
Object arg3) {
-		return Util.generateCsSQLException(messageId, arg1, arg2, arg3);
-	}
+    static SQLException newSQLException(String messageId, Object... args) {
+        return Util.generateCsSQLException(messageId, args);
+    }
 
 	/////////////////////////////////////////////////////////////////////////
 	//
@@ -3616,7 +3607,7 @@ public class EmbedConnection implements 
         EmbedSavepoint lsv = (EmbedSavepoint) savepoint;
         // bug 4451 need to throw error for null Savepoint
         if (lsv == null) {
-            throw Util.generateCsSQLException(
+            throw newSQLException(
                 SQLState.XACT_SAVEPOINT_NOT_FOUND, "null");
         }
 
@@ -3740,9 +3731,8 @@ public class EmbedConnection implements 
     public boolean isValid(int timeout) throws SQLException {
         // Validate that the timeout has a legal value
         if (timeout < 0) {
-            throw Util.generateCsSQLException(SQLState.INVALID_API_PARAMETER,
-                                              new Integer(timeout), "timeout",
-                                              "java.sql.Connection.isValid");
+            throw newSQLException(SQLState.INVALID_API_PARAMETER, timeout,
+                                  "timeout", "java.sql.Connection.isValid");
         }
 
         // Use the closed status for the connection to determine if the



Mime
View raw message