From d793e655144f1f0d829b13c63372e05ac7122416 Mon Sep 17 00:00:00 2001 From: Sergey Chernov Date: Thu, 19 Dec 2024 19:48:50 -0800 Subject: [PATCH] returning written rows right from response --- jdbc-v2/src/main/java/com/clickhouse/jdbc/StatementImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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