diff --git a/clickhouse-native-jdbc/src/main/java/com/github/housepower/jdbc/statement/ClickHousePreparedInsertStatement.java b/clickhouse-native-jdbc/src/main/java/com/github/housepower/jdbc/statement/ClickHousePreparedInsertStatement.java index 1e28ef7f..32bb7b3d 100644 --- a/clickhouse-native-jdbc/src/main/java/com/github/housepower/jdbc/statement/ClickHousePreparedInsertStatement.java +++ b/clickhouse-native-jdbc/src/main/java/com/github/housepower/jdbc/statement/ClickHousePreparedInsertStatement.java @@ -130,7 +130,7 @@ public int executeUpdate() throws SQLException { addParameters(); int result = connection.sendInsertRequest(block); this.blockInit = false; - this.block.initWriteBuffer(); + this.block.cleanup(); return result; } @@ -156,7 +156,7 @@ public int[] executeBatch() throws SQLException { Arrays.fill(result, 1); clearBatch(); this.blockInit = false; - this.block.initWriteBuffer(); + this.block.cleanup(); return result; } @@ -166,7 +166,6 @@ public void close() throws SQLException { // Empty insert when close. this.connection.sendInsertRequest(new Block()); this.blockInit = false; - this.block.initWriteBuffer(); } // clean up block on close this.block.cleanup(); diff --git a/clickhouse-native-jdbc/src/main/java/com/github/housepower/jdbc/statement/ClickHouseStatement.java b/clickhouse-native-jdbc/src/main/java/com/github/housepower/jdbc/statement/ClickHouseStatement.java index ca3d80f7..a47bef70 100644 --- a/clickhouse-native-jdbc/src/main/java/com/github/housepower/jdbc/statement/ClickHouseStatement.java +++ b/clickhouse-native-jdbc/src/main/java/com/github/housepower/jdbc/statement/ClickHouseStatement.java @@ -86,6 +86,7 @@ public int executeUpdate(String query) throws SQLException { block.initWriteBuffer(); new ValuesNativeInputFormat(matcher.end() - 1, query).fill(block); updateCount = connection.sendInsertRequest(block); + block.cleanup(); return updateCount; } updateCount = -1;