datasource

Raod 3 years ago
parent 5505368dfe
commit c777c0bb5a

@ -130,7 +130,7 @@ public class DataSetServiceImpl implements DataSetService {
JSONObject jsonObject = jsonArray.getJSONObject(0); JSONObject jsonObject = jsonArray.getJSONObject(0);
dto.setSetParamList(jsonObject.keySet()); dto.setSetParamList(jsonObject.keySet());
} catch (Exception e) { } catch (Exception e) {
log.error("{}",e); log.error("error",e);
} }
} }
return dto; return dto;

@ -61,10 +61,11 @@ public class JdbcUtil {
try { try {
DruidDataSource pool = map.get(id); DruidDataSource pool = map.get(id);
if (pool != null) { if (pool != null) {
log.info("remove pool success, datasourceId:{}", id);
map.remove(id); map.remove(id);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("{}",e); log.error("error",e);
} finally { } finally {
} }
} }

@ -94,6 +94,7 @@ public class DataSourceServiceImpl implements DataSourceService {
break; break;
case JdbcConstants.MYSQL: case JdbcConstants.MYSQL:
case JdbcConstants.KUDU_IMAPLA: case JdbcConstants.KUDU_IMAPLA:
case JdbcConstants.ORACLE:
testRelationalDb(dto); testRelationalDb(dto);
break; break;
case JdbcConstants.HTTP: case JdbcConstants.HTTP:
@ -115,6 +116,7 @@ public class DataSourceServiceImpl implements DataSourceService {
return executeElasticsearchSql(dto); return executeElasticsearchSql(dto);
case JdbcConstants.MYSQL: case JdbcConstants.MYSQL:
case JdbcConstants.KUDU_IMAPLA: case JdbcConstants.KUDU_IMAPLA:
case JdbcConstants.ORACLE:
return executeRelationalDb(dto); return executeRelationalDb(dto);
case JdbcConstants.HTTP: case JdbcConstants.HTTP:
return executeHttp(dto); return executeHttp(dto);
@ -176,7 +178,7 @@ public class DataSourceServiceImpl implements DataSourceService {
try { try {
exchange = restTemplate.exchange(dto.getApiUrl(), HttpMethod.valueOf(dto.getMethod()), entity, JSONObject.class); exchange = restTemplate.exchange(dto.getApiUrl(), HttpMethod.valueOf(dto.getMethod()), entity, JSONObject.class);
} catch (Exception e) { } catch (Exception e) {
log.error("{}",e); log.error("error",e);
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, e.getMessage()); throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, e.getMessage());
} }
if (exchange.getStatusCode().isError()) { if (exchange.getStatusCode().isError()) {
@ -203,7 +205,7 @@ public class DataSourceServiceImpl implements DataSourceService {
result.add(jsonObject); result.add(jsonObject);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("{}",e); log.error("error",e);
throw BusinessExceptionBuilder.build(ResponseCode.ANALYSIS_DATA_ERROR, e.getMessage()); throw BusinessExceptionBuilder.build(ResponseCode.ANALYSIS_DATA_ERROR, e.getMessage());
} }
return result; return result;
@ -233,7 +235,7 @@ public class DataSourceServiceImpl implements DataSourceService {
Object value = rs.getObject(t); Object value = rs.getObject(t);
jo.put(t, value); jo.put(t, value);
} catch (SQLException throwable) { } catch (SQLException throwable) {
log.error("{}",throwable); log.error("error",throwable);
throw BusinessExceptionBuilder.build(ResponseCode.EXECUTE_SQL_ERROR, throwable.getMessage()); throw BusinessExceptionBuilder.build(ResponseCode.EXECUTE_SQL_ERROR, throwable.getMessage());
} }
}); });
@ -241,7 +243,7 @@ public class DataSourceServiceImpl implements DataSourceService {
} }
return list; return list;
} catch (Exception throwable) { } catch (Exception throwable) {
log.error("{}",throwable); log.error("error",throwable);
throw BusinessExceptionBuilder.build(ResponseCode.EXECUTE_SQL_ERROR, throwable.getMessage()); throw BusinessExceptionBuilder.build(ResponseCode.EXECUTE_SQL_ERROR, throwable.getMessage());
} finally { } finally {
try { try {
@ -249,7 +251,7 @@ public class DataSourceServiceImpl implements DataSourceService {
pooledConnection.close(); pooledConnection.close();
} }
} catch (SQLException throwable) { } catch (SQLException throwable) {
log.error("{}",throwable); log.error("error",throwable);
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, throwable.getMessage()); throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, throwable.getMessage());
} }
} }
@ -269,7 +271,7 @@ public class DataSourceServiceImpl implements DataSourceService {
try { try {
exchange = restTemplate.exchange(dto.getApiUrl(), HttpMethod.valueOf(dto.getMethod()), entity, JSONObject.class); exchange = restTemplate.exchange(dto.getApiUrl(), HttpMethod.valueOf(dto.getMethod()), entity, JSONObject.class);
} catch (Exception e) { } catch (Exception e) {
log.error("{}",e); log.error("error",e);
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, e.getMessage()); throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, e.getMessage());
} }
if (exchange.getStatusCode().isError()) { if (exchange.getStatusCode().isError()) {
@ -294,7 +296,7 @@ public class DataSourceServiceImpl implements DataSourceService {
log.info("数据库测试连接成功:{}", catalog); log.info("数据库测试连接成功:{}", catalog);
unPooledConnection.close(); unPooledConnection.close();
} catch (Exception e) { } catch (Exception e) {
log.error("{}",e); log.error("error",e);
throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, e.getMessage()); throw BusinessExceptionBuilder.build(ResponseCode.DATA_SOURCE_CONNECTION_FAILED, e.getMessage());
} }
} }
@ -400,10 +402,6 @@ public class DataSourceServiceImpl implements DataSourceService {
*/ */
@Override @Override
public void processAfterOperation(DataSource entity, BaseOperationEnum operationEnum) throws BusinessException { public void processAfterOperation(DataSource entity, BaseOperationEnum operationEnum) throws BusinessException {
switch (operationEnum){ JdbcUtil.removeJdbcConnectionPool(entity.getId());
case DELETE:
JdbcUtil.removeJdbcConnectionPool(entity.getId());
break;
}
} }
} }

@ -23,7 +23,7 @@ public class FileUtils {
bos.close(); bos.close();
buffer = bos.toByteArray(); buffer = bos.toByteArray();
} catch (IOException e) { } catch (IOException e) {
log.error("{}", e); log.error("error", e);
} }
return buffer; return buffer;
} }

@ -83,7 +83,7 @@ public class UserServiceImpl implements UserService {
} }
return result.toString(); return result.toString();
} catch (Exception e) { } catch (Exception e) {
log.error("{}",e); log.error("error",e);
} }
return ""; return "";
} }

Loading…
Cancel
Save