Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2011-07-06 04:18:54 -0400
committerEike Stepper2011-07-06 04:18:54 -0400
commit1db6ed552d142478f7df15fa798ee53d9b558088 (patch)
tree8b65da5ce41490d61619970c225ca29bcd96eb54 /plugins
parentea637f75e42685a7694abf3f9acca7b6cc4f6de2 (diff)
downloadcdo-1db6ed552d142478f7df15fa798ee53d9b558088.tar.gz
cdo-1db6ed552d142478f7df15fa798ee53d9b558088.tar.xz
cdo-1db6ed552d142478f7df15fa798ee53d9b558088.zip
[344231] [DB] Improve Statement.executeBatch result checking
https://bugs.eclipse.org/bugs/show_bug.cgi?id=344231
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java28
-rw-r--r--plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF18
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java28
3 files changed, 41 insertions, 33 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java
index 0952a94f95..92d96aad20 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java
@@ -472,12 +472,7 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
TRACER.format("Performing {0} delete operations", deleteCounter); //$NON-NLS-1$
}
- int[] result = deleteStmt.executeBatch();
- Assert.isTrue(result.length == deleteCounter);
- for (int r : result)
- {
- Assert.isTrue(r == 1);
- }
+ DBUtil.executeBatch(deleteStmt, deleteCounter);
}
if (moveCounter > 0)
@@ -487,12 +482,7 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
TRACER.format("Performing {0} move operations", moveCounter); //$NON-NLS-1$
}
- int[] result = moveStmt.executeBatch();
- Assert.isTrue(result.length == moveCounter);
- for (int r : result)
- {
- Assert.isTrue(r == 1);
- }
+ DBUtil.executeBatch(moveStmt, moveCounter);
}
if (insertCounter > 0)
@@ -502,12 +492,7 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
TRACER.format("Performing {0} insert operations", insertCounter); //$NON-NLS-1$
}
- int[] result = insertStmt.executeBatch();
- Assert.isTrue(result.length == insertCounter);
- for (int r : result)
- {
- Assert.isTrue(r == 1);
- }
+ DBUtil.executeBatch(insertStmt, insertCounter);
}
if (setValueCounter > 0)
@@ -517,12 +502,7 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
TRACER.format("Performing {0} set operations", setValueCounter); //$NON-NLS-1$
}
- int[] result = setValueStmt.executeBatch();
- Assert.isTrue(result.length == setValueCounter);
- for (int r : result)
- {
- Assert.isTrue(r == 1);
- }
+ DBUtil.executeBatch(setValueStmt, setValueCounter);
}
}
catch (SQLException e)
diff --git a/plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF
index f5eb8abdaa..6b572e8144 100644
--- a/plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.net4j.db;singleton:=true
-Bundle-Version: 4.0.0.qualifier
+Bundle-Version: 4.1.0.qualifier
Bundle-Activator: org.eclipse.net4j.internal.db.bundle.OM$Activator
Bundle-Vendor: %providerName
Bundle-ClassPath: .
@@ -10,13 +10,13 @@ Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
org.eclipse.net4j.util;bundle-version="[3.0.0,4.0.0)";visibility:=reexport
-Export-Package: org.eclipse.net4j.db;version="4.0.0",
- org.eclipse.net4j.db.ddl;version="4.0.0",
- org.eclipse.net4j.db.dml;version="4.0.0",
- org.eclipse.net4j.internal.db;version="4.0.0";x-internal:=true,
- org.eclipse.net4j.internal.db.bundle;version="4.0.0";x-internal:=true,
- org.eclipse.net4j.internal.db.ddl;version="4.0.0";x-internal:=true,
- org.eclipse.net4j.internal.db.dml;version="4.0.0";x-internal:=true,
- org.eclipse.net4j.spi.db;version="4.0.0"
+Export-Package: org.eclipse.net4j.db;version="4.1.0",
+ org.eclipse.net4j.db.ddl;version="4.1.0",
+ org.eclipse.net4j.db.dml;version="4.1.0",
+ org.eclipse.net4j.internal.db;version="4.1.0";x-internal:=true,
+ org.eclipse.net4j.internal.db.bundle;version="4.1.0";x-internal:=true,
+ org.eclipse.net4j.internal.db.ddl;version="4.1.0";x-internal:=true,
+ org.eclipse.net4j.internal.db.dml;version="4.1.0";x-internal:=true,
+ org.eclipse.net4j.spi.db;version="4.1.0"
Bundle-ActivationPolicy: lazy
Eclipse-BuddyPolicy: registered
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
index c7f4b7df79..e19f028f0b 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
@@ -518,6 +518,34 @@ public final class DBUtil
}
}
+ /**
+ * @since 4.1
+ */
+ public static void executeBatch(PreparedStatement stmt, int counter)
+ {
+ try
+ {
+ int[] results = stmt.executeBatch();
+ if (results.length != counter)
+ {
+ throw new DBException("Statement has " + results.length + " results (expected: " + counter + ")");
+ }
+
+ for (int i = 0; i < results.length; i++)
+ {
+ int result = results[i];
+ if (result != 1 && result != Statement.SUCCESS_NO_INFO)
+ {
+ throw new DBException("Result " + i + " is not successful: " + result);
+ }
+ }
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ }
+
public static int update(Connection connection, String sql)
{
trace(sql);

Back to the top