Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java')
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java28
1 files changed, 28 insertions, 0 deletions
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