From 45f91e1f09a1c6907d0ab89bc36156d1ce6b977e Mon Sep 17 00:00:00 2001 From: lilyrubich Date: Wed, 21 Jan 2026 15:22:05 +0400 Subject: [PATCH 1/2] pass errorCode to SQLException --- .../java/com/clickhouse/jdbc/internal/ExceptionUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/ExceptionUtils.java b/jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/ExceptionUtils.java index b3a64fe4e..5bb34e660 100644 --- a/jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/ExceptionUtils.java +++ b/jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/ExceptionUtils.java @@ -63,8 +63,8 @@ public static SQLException toSqlState(String message, String debugMessage, Excep return new SQLException(exceptionMessage, SQL_STATE_CLIENT_ERROR, cause); } else if (cause instanceof ConnectionInitiationException) { return new SQLException(exceptionMessage, SQL_STATE_CONNECTION_EXCEPTION, cause); - } else if (cause instanceof ServerException) { - return new SQLException(exceptionMessage, SQL_STATE_DATA_EXCEPTION, cause); + } else if (cause instanceof ServerException se) { + return new SQLException(exceptionMessage, SQL_STATE_DATA_EXCEPTION, se.getCode(), cause); } else if (cause instanceof ClientException) { return new SQLException(exceptionMessage, SQL_STATE_CLIENT_ERROR, cause); } else if (cause instanceof MalformedURLException) { From 0df409c14e3a858ad142a6232cc821b0340dc0fe Mon Sep 17 00:00:00 2001 From: lilyrubich Date: Wed, 21 Jan 2026 20:53:12 +0400 Subject: [PATCH 2/2] server exception cast --- .../java/com/clickhouse/jdbc/internal/ExceptionUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/ExceptionUtils.java b/jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/ExceptionUtils.java index 5bb34e660..b86c01c4a 100644 --- a/jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/ExceptionUtils.java +++ b/jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/ExceptionUtils.java @@ -63,8 +63,8 @@ public static SQLException toSqlState(String message, String debugMessage, Excep return new SQLException(exceptionMessage, SQL_STATE_CLIENT_ERROR, cause); } else if (cause instanceof ConnectionInitiationException) { return new SQLException(exceptionMessage, SQL_STATE_CONNECTION_EXCEPTION, cause); - } else if (cause instanceof ServerException se) { - return new SQLException(exceptionMessage, SQL_STATE_DATA_EXCEPTION, se.getCode(), cause); + } else if (cause instanceof ServerException) { + return new SQLException(exceptionMessage, SQL_STATE_DATA_EXCEPTION, ((ServerException) cause).getCode(), cause); } else if (cause instanceof ClientException) { return new SQLException(exceptionMessage, SQL_STATE_CLIENT_ERROR, cause); } else if (cause instanceof MalformedURLException) {