use of com.varsql.core.common.beans.FileInfo in project varsql by varsqlinfo.
the class DriverProvierMgmtServiceImpl method driverCheck.
public ResponseResult driverCheck(DBTypeDriverProviderRequestDTO dto) throws EncryptDecryptException {
ResponseResult resultObject = new ResponseResult();
String driverProviderId = dto.getDriverProviderId();
DBTypeDriverProviderEntity entity = dbTypeDriverProviderRepository.findByDriverProviderId(driverProviderId);
if (entity == null) {
resultObject.setResultCode(RequestResultCode.NOT_FOUND);
resultObject.setMessage("db jdbc provider not found : " + driverProviderId);
return resultObject;
}
StringBuffer errorMsg = new StringBuffer();
try {
List<FileInfo> driverJarFiles;
if (PathType.PATH.equals(PathType.getPathType(dto.getPathType()))) {
driverJarFiles = FileServiceUtils.getFileInfos(dto.getDriverPath().split(";"));
} else {
driverJarFiles = FileServiceUtils.getFileInfos(dbTypeDriverFileEntityRepository.findByFileContId(entity.getDriverProviderId()));
}
JDBCDriverInfo jdbcDriverInfo = new JDBCDriverInfo(dto.getDriverProviderId(), dto.getDriverClass());
jdbcDriverInfo.setDriverFiles(driverJarFiles);
if (JdbcDriverLoader.checkDriver(jdbcDriverInfo) != null) {
resultObject.setResultCode(VarsqlAppCode.SUCCESS);
} else {
resultObject.setMessage("driver null");
resultObject.setResultCode(VarsqlAppCode.ERROR);
}
resultObject.setResultCode(VarsqlAppCode.SUCCESS);
} catch (ClassNotFoundException e) {
resultObject.setResultCode(VarsqlAppCode.ERROR);
resultObject.setMessage("class not found : " + dto.getDriverClass() + "\nerror message : " + e.getMessage());
logger.error(getClass().getName(), e);
} catch (Exception e) {
resultObject.setResultCode(VarsqlAppCode.ERROR);
resultObject.setMessage(e.getMessage() + BlankConstants.NEW_LINE + errorMsg);
logger.error(getClass().getName(), e);
}
return resultObject;
}
Aggregations