From c777c0bb5a12f2d0a675319b61cbb59d805ac6d5 Mon Sep 17 00:00:00 2001 From: Raod <1130305001@qq.com> Date: Fri, 16 Jul 2021 13:11:17 +0800 Subject: [PATCH] datasource --- .../service/impl/DataSetServiceImpl.java | 2 +- .../dataSource/pool/util/JdbcUtil.java | 3 ++- .../service/impl/DataSourceServiceImpl.java | 22 +++++++++---------- .../business/modules/file/util/FileUtils.java | 2 +- .../user/service/impl/UserServiceImpl.java | 2 +- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataSet/service/impl/DataSetServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataSet/service/impl/DataSetServiceImpl.java index 8513640a..6fcffa61 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataSet/service/impl/DataSetServiceImpl.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataSet/service/impl/DataSetServiceImpl.java @@ -130,7 +130,7 @@ public class DataSetServiceImpl implements DataSetService { JSONObject jsonObject = jsonArray.getJSONObject(0); dto.setSetParamList(jsonObject.keySet()); } catch (Exception e) { - log.error("{}",e); + log.error("error",e); } } return dto; diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataSource/pool/util/JdbcUtil.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataSource/pool/util/JdbcUtil.java index cbcf3957..98217c61 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataSource/pool/util/JdbcUtil.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataSource/pool/util/JdbcUtil.java @@ -61,10 +61,11 @@ public class JdbcUtil { try { DruidDataSource pool = map.get(id); if (pool != null) { + log.info("remove pool success, datasourceId:{}", id); map.remove(id); } } catch (Exception e) { - log.error("{}",e); + log.error("error",e); } finally { } } diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataSource/service/impl/DataSourceServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataSource/service/impl/DataSourceServiceImpl.java index 29705d47..f68ba7c9 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataSource/service/impl/DataSourceServiceImpl.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataSource/service/impl/DataSourceServiceImpl.java @@ -94,6 +94,7 @@ public class DataSourceServiceImpl implements DataSourceService { break; case JdbcConstants.MYSQL: case JdbcConstants.KUDU_IMAPLA: + case JdbcConstants.ORACLE: testRelationalDb(dto); break; case JdbcConstants.HTTP: @@ -115,6 +116,7 @@ public class DataSourceServiceImpl implements DataSourceService { return executeElasticsearchSql(dto); case JdbcConstants.MYSQL: case JdbcConstants.KUDU_IMAPLA: + case JdbcConstants.ORACLE: return executeRelationalDb(dto); case JdbcConstants.HTTP: return executeHttp(dto); @@ -176,7 +178,7 @@ public class DataSourceServiceImpl implements DataSourceService { try { exchange = restTemplate.exchange(dto.getApiUrl(), HttpMethod.valueOf(dto.getMethod()), entity, JSONObject.class); } catch (Exception e) { - log.error("{}",e); + log.error("error",e); throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, e.getMessage()); } if (exchange.getStatusCode().isError()) { @@ -203,7 +205,7 @@ public class DataSourceServiceImpl implements DataSourceService { result.add(jsonObject); } } catch (Exception e) { - log.error("{}",e); + log.error("error",e); throw BusinessExceptionBuilder.build(ResponseCode.ANALYSIS_DATA_ERROR, e.getMessage()); } return result; @@ -233,7 +235,7 @@ public class DataSourceServiceImpl implements DataSourceService { Object value = rs.getObject(t); jo.put(t, value); } catch (SQLException throwable) { - log.error("{}",throwable); + log.error("error",throwable); throw BusinessExceptionBuilder.build(ResponseCode.EXECUTE_SQL_ERROR, throwable.getMessage()); } }); @@ -241,7 +243,7 @@ public class DataSourceServiceImpl implements DataSourceService { } return list; } catch (Exception throwable) { - log.error("{}",throwable); + log.error("error",throwable); throw BusinessExceptionBuilder.build(ResponseCode.EXECUTE_SQL_ERROR, throwable.getMessage()); } finally { try { @@ -249,7 +251,7 @@ public class DataSourceServiceImpl implements DataSourceService { pooledConnection.close(); } } catch (SQLException throwable) { - log.error("{}",throwable); + log.error("error",throwable); throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, throwable.getMessage()); } } @@ -269,7 +271,7 @@ public class DataSourceServiceImpl implements DataSourceService { try { exchange = restTemplate.exchange(dto.getApiUrl(), HttpMethod.valueOf(dto.getMethod()), entity, JSONObject.class); } catch (Exception e) { - log.error("{}",e); + log.error("error",e); throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, e.getMessage()); } if (exchange.getStatusCode().isError()) { @@ -294,7 +296,7 @@ public class DataSourceServiceImpl implements DataSourceService { log.info("数据库测试连接成功:{}", catalog); unPooledConnection.close(); } catch (Exception e) { - log.error("{}",e); + log.error("error",e); throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, e.getMessage()); } } @@ -400,10 +402,6 @@ public class DataSourceServiceImpl implements DataSourceService { */ @Override public void processAfterOperation(DataSource entity, BaseOperationEnum operationEnum) throws BusinessException { - switch (operationEnum){ - case DELETE: - JdbcUtil.removeJdbcConnectionPool(entity.getId()); - break; - } + JdbcUtil.removeJdbcConnectionPool(entity.getId()); } } diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/util/FileUtils.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/util/FileUtils.java index c0cb07e1..fca211bb 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/util/FileUtils.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/util/FileUtils.java @@ -23,7 +23,7 @@ public class FileUtils { bos.close(); buffer = bos.toByteArray(); } catch (IOException e) { - log.error("{}", e); + log.error("error", e); } return buffer; } diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/service/impl/UserServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/service/impl/UserServiceImpl.java index d1ddb9a8..b37eda21 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/service/impl/UserServiceImpl.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/user/service/impl/UserServiceImpl.java @@ -83,7 +83,7 @@ public class UserServiceImpl implements UserService { } return result.toString(); } catch (Exception e) { - log.error("{}",e); + log.error("error",e); } return ""; }