From e3488f1e09dc4f7ca10076471b32da1f5099b5c4 Mon Sep 17 00:00:00 2001 From: dailai Date: Fri, 13 Sep 2024 13:29:10 +0800 Subject: [PATCH] [Improve][Connector-v2] Throw Exception in sql query for JdbcCatalog of tb or db exists query --- .../jdbc/catalog/AbstractJdbcCatalog.java | 21 +++++++++---------- .../jdbc/catalog/iris/IrisCatalog.java | 10 ++++++--- .../oceanbase/OceanBaseOracleCatalog.java | 12 ++++++++--- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/AbstractJdbcCatalog.java b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/AbstractJdbcCatalog.java index 69f1007b6c1..e971c138930 100644 --- a/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/AbstractJdbcCatalog.java +++ b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/AbstractJdbcCatalog.java @@ -37,6 +37,7 @@ import org.apache.seatunnel.common.exception.CommonErrorCode; import org.apache.seatunnel.common.exception.SeaTunnelRuntimeException; import org.apache.seatunnel.common.utils.JdbcUrlUtil; +import org.apache.seatunnel.common.utils.SeaTunnelException; import org.apache.seatunnel.connectors.seatunnel.jdbc.catalog.utils.CatalogUtils; import org.apache.commons.lang3.StringUtils; @@ -279,9 +280,7 @@ public boolean databaseExists(String databaseName) throws CatalogException { return false; } try { - return querySQLResultExists( - getUrlFromDatabaseName(databaseName), - getDatabaseWithConditionSql(databaseName)); + return querySQLResultExists(defaultUrl, getDatabaseWithConditionSql(databaseName)); } catch (SeaTunnelRuntimeException e) { if (e.getSeaTunnelErrorCode().getCode().equals(UNSUPPORTED_METHOD.getCode())) { log.warn( @@ -290,6 +289,8 @@ public boolean databaseExists(String databaseName) throws CatalogException { return listDatabases().contains(databaseName); } throw e; + } catch (SQLException e) { + throw new SeaTunnelException("Failed to querySQLResult", e); } } @@ -350,6 +351,8 @@ && listTables(tablePath.getDatabaseName()) } } throw e1; + } catch (SQLException e) { + throw new SeaTunnelException("Failed to querySQLResult", e); } } @@ -566,14 +569,10 @@ protected List queryString(String url, String sql, ResultSetConsumer