From 3e9abcb9d16e179be7b644ee89b5e493e421f7f0 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Mon, 23 May 2022 19:44:24 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=89=93=E5=8D=B0=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataease/provider/datasource/JdbcProvider.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/src/main/java/io/dataease/provider/datasource/JdbcProvider.java b/backend/src/main/java/io/dataease/provider/datasource/JdbcProvider.java index d012b23055..949be78b86 100644 --- a/backend/src/main/java/io/dataease/provider/datasource/JdbcProvider.java +++ b/backend/src/main/java/io/dataease/provider/datasource/JdbcProvider.java @@ -3,6 +3,7 @@ package io.dataease.provider.datasource; import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.pool.DruidPooledConnection; import com.google.gson.Gson; +import io.dataease.commons.utils.LogUtil; import io.dataease.dto.datasource.*; import io.dataease.exception.DataEaseException; import io.dataease.i18n.Translator; @@ -299,6 +300,17 @@ public class JdbcProvider extends DefaultJdbcProvider { return list; } + @Override + public String checkStatus(DatasourceRequest datasourceRequest) throws Exception { + String queryStr = getTablesSql(datasourceRequest); + try (Connection con = getConnection(datasourceRequest); Statement statement = con.createStatement(); ResultSet resultSet = statement.executeQuery(queryStr)) { + } catch (Exception e) { + LogUtil.error("Datasource is invalid: " + datasourceRequest.getDatasource().getName() , e); + io.dataease.plugins.common.exception.DataEaseException.throwException(e.getMessage()); + } + return "Success"; + } + @Override public Connection getConnection(DatasourceRequest datasourceRequest) throws Exception { String username = null;