From 0ca6165d3b25d07da0e5bc03c0780adffc612032 Mon Sep 17 00:00:00 2001 From: Dmitriy Dumanskiy Date: Sat, 14 Sep 2019 10:38:41 +0300 Subject: [PATCH] #24 correctly reset preparedStatement --- .../ClickHousePreparedStatementImpl.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/cc/blynk/clickhouse/ClickHousePreparedStatementImpl.java b/src/main/java/cc/blynk/clickhouse/ClickHousePreparedStatementImpl.java index 4c0c6e5..2c073bb 100644 --- a/src/main/java/cc/blynk/clickhouse/ClickHousePreparedStatementImpl.java +++ b/src/main/java/cc/blynk/clickhouse/ClickHousePreparedStatementImpl.java @@ -54,7 +54,7 @@ public final class ClickHousePreparedStatementImpl extends ClickHouseStatementIm private final List sqlParts; private final ClickHousePreparedStatementParameter[] binds; private final String[][] parameterList; - private List batchRows = new ArrayList<>(); + private final List batchRows = new ArrayList<>(); ClickHousePreparedStatementImpl(HttpConnector connector, ClickHouseConnection connection, @@ -122,7 +122,14 @@ public ResultSet executeQuery() throws SQLException { @Override public void clearBatch() { - batchRows.clear(); + this.batchRows.clear(); + clearParameters(); + } + + @Override + public void close() throws SQLException { + super.close(); + clearBatch(); } @Override @@ -339,11 +346,10 @@ public int[] executeBatch(Map additionalDBParams) httpConnector.post(insertSql, batchRows, uri); int[] result = new int[batchRows.size()]; Arrays.fill(result, 1); - batchRows = new ArrayList<>(); + batchRows.clear(); return result; } - @Override public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException { throw new SQLFeatureNotSupportedException();