diff --git a/core/core-backend/src/main/java/io/dataease/datasource/server/DatasourceServer.java b/core/core-backend/src/main/java/io/dataease/datasource/server/DatasourceServer.java index d34c246923..b66e6e2ae8 100644 --- a/core/core-backend/src/main/java/io/dataease/datasource/server/DatasourceServer.java +++ b/core/core-backend/src/main/java/io/dataease/datasource/server/DatasourceServer.java @@ -34,6 +34,7 @@ import io.dataease.datasource.provider.ApiUtils; import io.dataease.datasource.provider.CalciteProvider; import io.dataease.datasource.provider.ExcelUtils; import io.dataease.datasource.request.DatasourceRequest; +import io.dataease.datasource.type.Pg; import io.dataease.engine.constant.SQLConstants; import io.dataease.exception.DEException; import io.dataease.i18n.Translator; @@ -265,7 +266,9 @@ public class DatasourceServer implements DatasourceApi { DEException.throwException("Failed to create table " + datasourceRequest.getTable()); } } - datasourceSyncManage.extractExcelData(coreDatasource, "all_scope"); + commonThreadPool.addTask(() -> { + datasourceSyncManage.extractExcelData(coreDatasource, "all_scope"); + }); } else if (dataSourceDTO.getType().equals(DatasourceConfiguration.DatasourceType.API.name())) { CoreDatasourceTask coreDatasourceTask = new CoreDatasourceTask(); BeanUtils.copyBean(coreDatasourceTask, dataSourceDTO.getSyncSetting()); @@ -298,11 +301,28 @@ public class DatasourceServer implements DatasourceApi { } } } else { + checkParams(dataSourceDTO.getConfiguration()); calciteProvider.update(dataSourceDTO); } return dataSourceDTO; } + private static void checkParams(String configurationStr) { + DatasourceConfiguration configuration = JsonUtil.parseObject(configurationStr, DatasourceConfiguration.class); + if(configuration.getInitialPoolSize() < configuration.getMinPoolSize()){ + DEException.throwException("初始连接数不能小于最小连接数!"); + } + if(configuration.getInitialPoolSize() > configuration.getMaxPoolSize()){ + DEException.throwException("初始连接数不能大于最大连接数!"); + } + if(configuration.getMaxPoolSize() < configuration.getMinPoolSize()){ + DEException.throwException("最大连接数不能小于最小连接数!"); + } + if(configuration.getQueryTimeout() < 0){ + DEException.throwException("查询超时不能小于0!"); + } + } + private static void checkName(List tables) { for (int i = 0; i < tables.size() - 1; i++) { for (int j = i + 1; j < tables.size(); j++) { @@ -419,6 +439,7 @@ public class DatasourceServer implements DatasourceApi { dataSourceManage.innerEdit(requestDatasource); } } else { + checkParams(dataSourceDTO.getConfiguration()); dataSourceManage.innerEdit(requestDatasource); calciteProvider.update(dataSourceDTO); } diff --git a/core/core-backend/src/main/java/io/dataease/datasource/type/Mysql.java b/core/core-backend/src/main/java/io/dataease/datasource/type/Mysql.java index bdf9392570..aa4290a444 100644 --- a/core/core-backend/src/main/java/io/dataease/datasource/type/Mysql.java +++ b/core/core-backend/src/main/java/io/dataease/datasource/type/Mysql.java @@ -13,7 +13,7 @@ import java.util.List; public class Mysql extends DatasourceConfiguration { private String driver = "com.mysql.cj.jdbc.Driver"; private String extraParams = "characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true&zeroDateTimeBehavior=convertToNull"; - private List illegalParameters = Arrays.asList("autoDeserialize", "queryInterceptors", "statementInterceptors", "detectCustomCollations"); + private List illegalParameters = Arrays.asList("autoDeserialize", "queryInterceptors", "statementInterceptors", "detectCustomCollations", "allowloadlocalinfile", "allowUrlInLocalInfile", "allowLoadLocalInfileInPath"); private List showTableSqls = Arrays.asList("show tables"); public String getJdbc() { @@ -24,7 +24,7 @@ public class Mysql extends DatasourceConfiguration { .replace("DATABASE", getDataBase().trim()); } else { for (String illegalParameter : illegalParameters) { - if (getExtraParams().contains(illegalParameter)) { + if (getExtraParams().toLowerCase().contains(illegalParameter.toLowerCase())) { throw new RuntimeException("Illegal parameter: " + illegalParameter); } }