From 57427955db0f463951aeed3b25cd3733bfb31a71 Mon Sep 17 00:00:00 2001 From: junjun Date: Mon, 14 Oct 2024 10:38:32 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=95=B0=E6=8D=AE=E6=BA=90):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=95=B0=E6=8D=AE=E6=BA=90=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E6=B1=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datasource/provider/CalciteProvider.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java b/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java index 02d993a42f..d4be5cea7c 100644 --- a/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java +++ b/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java @@ -1345,13 +1345,18 @@ public class CalciteProvider extends Provider { return connection; } - private Connection getConnectionFromPool(Long dsId) throws SQLException { - Connection connection = take(); - CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class); - SchemaPlus rootSchema = calciteConnection.getRootSchema(); - JdbcSchema jdbcSchema = rootSchema.getSubSchema(String.format(SQLConstants.SCHEMA, dsId)).unwrap(JdbcSchema.class); - BasicDataSource basicDataSource = (BasicDataSource) jdbcSchema.getDataSource(); - return basicDataSource.getConnection(); + private Connection getConnectionFromPool(Long dsId) { + try { + Connection connection = take(); + CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class); + SchemaPlus rootSchema = calciteConnection.getRootSchema(); + JdbcSchema jdbcSchema = rootSchema.getSubSchema(String.format(SQLConstants.SCHEMA, dsId)).unwrap(JdbcSchema.class); + BasicDataSource basicDataSource = (BasicDataSource) jdbcSchema.getDataSource(); + return basicDataSource.getConnection(); + } catch (Exception e) { + DEException.throwException("连接无效"); + } + return null; } public void exec(EngineRequest engineRequest) throws Exception {