Skip to content

Commit

Permalink
[bug fix] Use PreparedStatement objects under thread-safe conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
itinycheng committed Aug 16, 2021
1 parent 0e5d3f4 commit 3451515
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ public synchronized void addToBatch(RowData record) throws SQLException {
}

@Override
public void executeBatch() throws SQLException {
public synchronized void executeBatch() throws SQLException {
statement.executeBatch();
}

@Override
public void closeStatement() throws SQLException {
public synchronized void closeStatement() throws SQLException {
if (statement != null) {
statement.close();
statement = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public synchronized void addToBatch(RowData record) throws SQLException {
}

@Override
public void executeBatch() throws SQLException {
public synchronized void executeBatch() throws SQLException {
for (ClickHousePreparedStatement clickHousePreparedStatement :
Arrays.asList(insertStmt, updateStmt, deleteStmt)) {
if (clickHousePreparedStatement != null) {
Expand All @@ -107,7 +107,7 @@ public void executeBatch() throws SQLException {
}

@Override
public void closeStatement() throws SQLException {
public synchronized void closeStatement() throws SQLException {
for (ClickHousePreparedStatement clickHousePreparedStatement :
Arrays.asList(insertStmt, updateStmt, deleteStmt)) {
if (clickHousePreparedStatement != null) {
Expand Down

0 comments on commit 3451515

Please sign in to comment.