diff --git a/jdbc-v2/src/main/java/com/clickhouse/jdbc/StatementImpl.java b/jdbc-v2/src/main/java/com/clickhouse/jdbc/StatementImpl.java index 32efbc1f5..0fab7eb5c 100644 --- a/jdbc-v2/src/main/java/com/clickhouse/jdbc/StatementImpl.java +++ b/jdbc-v2/src/main/java/com/clickhouse/jdbc/StatementImpl.java @@ -193,16 +193,18 @@ public int executeUpdate(String sql, QuerySettings settings) throws SQLException QuerySettings mergedSettings = QuerySettings.merge(connection.getDefaultQuerySettings(), settings); mergedSettings.serverSetting(ServerSettings.WAIT_END_OF_QUERY, "1"); lastSql = parseJdbcEscapeSyntax(sql); + int updateCount = 0; try (QueryResponse response = queryTimeout == 0 ? connection.client.query(lastSql, mergedSettings).get() : connection.client.query(lastSql, mergedSettings).get(queryTimeout, TimeUnit.SECONDS)) { currentResultSet = null; + updateCount = (int) response.getWrittenRows(); metrics = response.getMetrics(); lastQueryId = response.getQueryId(); } catch (Exception e) { throw ExceptionUtils.toSqlState(e); } - return (int) metrics.getMetric(ServerMetrics.NUM_ROWS_WRITTEN).getLong(); + return updateCount; } @Override