# HG changeset patch
# User Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
# Date 1599665539 -7200
# Node ID 253363a2ae289cc6b41a80fd5830f598e04ff563
# Parent  a06a76170d39bf6bee46bf7071e614fbfaca198b
Fix for bug 6953.
Also updated Test_Sbatching.java such that no clearBatch() is called anymore after each executeBatch() in a loop.

diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java b/src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java
@@ -254,6 +254,7 @@ public class MonetStatement
 			// otherwise just return the counts
 			return counts;
 		} finally {
+			batch.clear();
 			batchLock.unlock();
 		}
 	}
diff --git a/tests/Test_Sbatching.java b/tests/Test_Sbatching.java
--- a/tests/Test_Sbatching.java
+++ b/tests/Test_Sbatching.java
@@ -33,22 +33,25 @@ public class Test_Sbatching {
 					int[] cnts = stmt.executeBatch();
 					System.out.println("passed :)");
 					System.out.print("3. checking number of update counts...");
-					if (cnts.length != 400) throw new SQLException("Invalid size: " + cnts.length);
+					if (cnts.length != 400)
+						throw new SQLException("Invalid size: " + cnts.length);
 					System.out.println(cnts.length + " passed :)");
 					System.out.print("4. checking update counts (should all be 1)...");
 					for (int j = 0; j < cnts.length; j++) {
-						if (cnts[j] != 1) throw new SQLException("Unexpected value: " + cnts[j]);
+						if (cnts[j] != 1)
+							throw new SQLException("Unexpected value: " + cnts[j]);
 					}
 					System.out.println("passed :)");
-					System.out.print("5. clearing the batch...");
-					stmt.clearBatch();
-					System.out.println("passed :)");
 				}
 			}
-			System.out.print("6. executing batch...");
+			System.out.print("5. executing batch...");
 			stmt.executeBatch();
 			System.out.println("passed :)");
 
+			System.out.print("6. clearing the batch...");
+			stmt.clearBatch();
+			System.out.println("passed :)");
+
 			System.out.print("7. checking table count...");
 			rs = stmt.executeQuery("SELECT COUNT(*) FROM table_Test_Sbatching");
 			rs.next();