Skip to content

Commit

Permalink
#24 correctly reset preparedStatement
Browse files Browse the repository at this point in the history
  • Loading branch information
doom369 committed Sep 14, 2019
1 parent 1f4b996 commit 0ca6165
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public final class ClickHousePreparedStatementImpl extends ClickHouseStatementIm
private final List<String> sqlParts;
private final ClickHousePreparedStatementParameter[] binds;
private final String[][] parameterList;
private List<byte[]> batchRows = new ArrayList<>();
private final List<byte[]> batchRows = new ArrayList<>();

ClickHousePreparedStatementImpl(HttpConnector connector,
ClickHouseConnection connection,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -339,11 +346,10 @@ public int[] executeBatch(Map<ClickHouseQueryParam, String> 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();
Expand Down

0 comments on commit 0ca6165

Please sign in to comment.