refactor: 打印日志

This commit is contained in:
taojinlong 2022-05-23 19:44:24 +08:00
parent c657f56c29
commit 3e9abcb9d1

View File

@ -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;