This is an automated email from the ASF dual-hosted git repository.

mihaibudiu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/main by this push:
     new 76af08e3bb [CALCITE-5121] Rethrow RuntimeException as SQLException in 
Driver#onConnectionInit
76af08e3bb is described below

commit 76af08e3bb2ee0e2c599130df778908b59f57da6
Author: 1fanwang <[email protected]>
AuthorDate: Thu Oct 1 20:26:15 2026 -0700

    [CALCITE-5121] Rethrow RuntimeException as SQLException in 
Driver#onConnectionInit
    
    Signed-off-by: 1fanwang <[email protected]>
---
 core/src/main/java/org/apache/calcite/jdbc/Driver.java             | 2 +-
 core/src/test/java/org/apache/calcite/test/JdbcTest.java           | 7 +++++++
 .../test/java/org/apache/calcite/adapter/file/FileAdapterTest.java | 2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/jdbc/Driver.java 
b/core/src/main/java/org/apache/calcite/jdbc/Driver.java
index 5db1f15864..63c916013e 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/Driver.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/Driver.java
@@ -149,7 +149,7 @@ protected Function0<CalcitePrepare> createPrepareFactory() {
             if (defaultName != null) {
               connection.setSchema(defaultName);
             }
-          } catch (IOException e) {
+          } catch (IOException | RuntimeException e) {
             throw new SQLException(e);
           }
         }
diff --git a/core/src/test/java/org/apache/calcite/test/JdbcTest.java 
b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
index f0b675960e..0109d3f954 100644
--- a/core/src/test/java/org/apache/calcite/test/JdbcTest.java
+++ b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
@@ -6835,6 +6835,13 @@ private void checkCustomSchema(String url, String 
schemaName) throws SQLExceptio
     checkJdbcSchemaDirectConnection("schemaType=JDBC");
   }
 
+  @Test void testJdbcSchemaDirectConnectionInitWrapsRuntimeException() {
+    final SQLException e = assertThrows(SQLException.class, () ->
+        DriverManager.getConnection(
+            "jdbc:calcite:schemaType=JDBC;schema.jdbcUrl=jdbc:invalid:"));
+    assertThat(e.getCause(), instanceOf(RuntimeException.class));
+  }
+
   private void checkJdbcSchemaDirectConnection(String s) throws SQLException {
     final StringBuilder b = new StringBuilder("jdbc:calcite:");
     b.append(s);
diff --git 
a/file/src/test/java/org/apache/calcite/adapter/file/FileAdapterTest.java 
b/file/src/test/java/org/apache/calcite/adapter/file/FileAdapterTest.java
index f818c8a156..f9364c65a4 100644
--- a/file/src/test/java/org/apache/calcite/adapter/file/FileAdapterTest.java
+++ b/file/src/test/java/org/apache/calcite/adapter/file/FileAdapterTest.java
@@ -408,7 +408,7 @@ private static void checkEmpty(ResultSet resultSet) {
           DriverManager.getConnection("jdbc:calcite:", info);
       connection.close();
       throw new AssertionError("expected error");
-    } catch (RuntimeException e) {
+    } catch (SQLException e) {
       Throwable cause = e;
       while (cause.getCause() != null) {
         cause = cause.getCause();

Reply via email to