db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1443086 - in /db/derby/code/trunk/java: client/org/apache/derby/client/net/ engine/org/apache/derby/impl/jdbc/
Date Wed, 06 Feb 2013 17:39:42 GMT
Author: rhillegas
Date: Wed Feb  6 17:39:42 2013
New Revision: 1443086

URL: http://svn.apache.org/viewvc?rev=1443086&view=rev
Log:
DERBY-6000: Fix bug on contruction of BatchUpdateExceptions.

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl42.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java?rev=1443086&r1=1443085&r2=1443086&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java
(original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java
Wed Feb  6 17:39:42 2013
@@ -445,24 +445,31 @@ public class ClientJDBCObjectFactoryImpl
              msgutil_.getCompleteMessage( msgid.msgid, args),
              ExceptionUtil.getSQLStateFromIdentifier(msgid.msgid),
              ExceptionUtil.getSeverityFromIdentifier(msgid.msgid),
-             updateCounts
+             updateCounts,
+             cause
              );
     
         if (logWriter != null) {
             logWriter.traceDiagnosable( bue );
         }
-
+    
         if (cause != null) {
-            bue.initCause(cause);
             bue.setNextException(cause.getSQLException());
         }
-    
+
         return bue;
     }
     /** This method is overriden on JVM 8 */
     protected   java.sql.BatchUpdateException   newBatchUpdateException
-        ( String message, String sqlState, int errorCode, long[] updateCounts )
+        ( String message, String sqlState, int errorCode, long[] updateCounts, SqlException
cause  )
     {
-        return new java.sql.BatchUpdateException( message, sqlState, errorCode, Utils.squashLongs(
updateCounts ) );
+        java.sql.BatchUpdateException bue = new java.sql.BatchUpdateException
+            ( message, sqlState, errorCode, Utils.squashLongs( updateCounts ) );
+
+        if (cause != null) {
+            bue.initCause(cause);
+        }
+
+        return bue;
     }
 }

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl42.java?rev=1443086&r1=1443085&r2=1443086&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl42.java
(original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl42.java
Wed Feb  6 17:39:42 2013
@@ -21,6 +21,8 @@
 
 package org.apache.derby.client.net;
 
+import org.apache.derby.client.am.SqlException;
+
 /**
  * Implements the ClientJDBCObjectFactory interface and returns the JDBC 4.2
  * specific classes.
@@ -29,9 +31,9 @@ public class ClientJDBCObjectFactoryImpl
 {
     /** This method is overriden on JVM 8 to take advantage of long update counts */
     protected   java.sql.BatchUpdateException   newBatchUpdateException
-        ( String message, String sqlState, int errorCode, long[] updateCounts )
+        ( String message, String sqlState, int errorCode, long[] updateCounts, SqlException
cause )
     {
-        return new java.sql.BatchUpdateException( message, sqlState, errorCode, updateCounts,
null );
+        return new java.sql.BatchUpdateException( message, sqlState, errorCode, updateCounts,
cause );
     }
 }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java?rev=1443086&r1=1443085&r2=1443086&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java Wed Feb
 6 17:39:42 2013
@@ -1111,10 +1111,8 @@ public class EmbedStatement extends Conn
             System.arraycopy(returnUpdateCountForBatch, 0, successfulUpdateCount, 0, i);
 
 			SQLException batch = Util.newBatchUpdateException
-                ( sqle.getMessage(), sqle.getSQLState(),sqle.getErrorCode(), successfulUpdateCount
);
+                ( sqle.getMessage(), sqle.getSQLState(),sqle.getErrorCode(), successfulUpdateCount,
sqle );
 
-			batch.setNextException(sqle);
-			batch.initCause(sqle);
 			throw batch;
       }
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java?rev=1443086&r1=1443085&r2=1443086&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java Wed Feb  6 17:39:42
2013
@@ -342,7 +342,7 @@ public abstract class Util  {
 
     /** Create the correct BatchUpdateException depending on whether this is Java 8 or lower
*/
     static  SQLException    newBatchUpdateException
-        ( String message, String sqlState, int errorCode, long[] updateCounts )
+        ( String message, String sqlState, int errorCode, long[] updateCounts, Throwable
cause )
     {
         if ( JVMInfo.JDK_ID >= JVMInfo.J2SE_18 )
         {
@@ -353,7 +353,7 @@ public abstract class Util  {
                      );
 
                 return (BatchUpdateException) constructor.newInstance
-                    ( new Object[] { message, sqlState, new Integer( errorCode ), updateCounts,
(Throwable) null } );
+                    ( new Object[] { message, sqlState, new Integer( errorCode ), updateCounts,
cause } );
             }
             catch (Exception e)
             {
@@ -364,8 +364,13 @@ public abstract class Util  {
 
         // use this constructor if we're not on Java 8 or if an error occurred
         // while using the Java 8 constructor
-        return new BatchUpdateException
+        BatchUpdateException batch = new BatchUpdateException
             ( message, sqlState, errorCode, squashLongs( updateCounts ) );
+        
+        if ( cause instanceof SQLException ) { batch.setNextException( (SQLException) cause
); }
+        batch.initCause( cause );
+
+        return batch;
     }
 
     /** Squash an array of longs into an array of ints */



Mime
View raw message