diff --git a/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/util/CommonUtils.java b/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/util/CommonUtils.java index 7f1390d8..85614080 100644 --- a/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/util/CommonUtils.java +++ b/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/util/CommonUtils.java @@ -30,6 +30,10 @@ import lombok.extern.slf4j.Slf4j; @Slf4j public class CommonUtils { + private CommonUtils(){ + + } + //中文正则 private static Pattern ZHONGWEN_PATTERN = Pattern.compile("[\u4e00-\u9fa5]"); @@ -188,7 +192,6 @@ public class CommonUtils { try { return getDatabaseTypeByDataSource(dataSource); } catch (SQLException e) { - //e.printStackTrace(); log.warn(e.getMessage(), e); return ""; } @@ -202,9 +205,9 @@ public class CommonUtils { if (oConvertUtils.isNotEmpty(dbTypeEnum)) { return dbTypeEnum; } - try { - DataSource dataSource = SpringContextUtils.getApplicationContext().getBean(DataSource.class); - dbTypeEnum = JdbcUtils.getDbType(dataSource.getConnection().getMetaData().getURL()); + DataSource dataSource = SpringContextUtils.getApplicationContext().getBean(DataSource.class); + try (Connection connection = dataSource.getConnection();) { + dbTypeEnum = JdbcUtils.getDbType(connection.getMetaData().getURL()); return dbTypeEnum; } catch (SQLException e) { log.warn(e.getMessage(), e); @@ -262,10 +265,10 @@ public class CommonUtils { * @param RSAPrivateKey 私钥 * @return String 解密后的字符串 */ - public static String decryptBtRsaPriKey(String str,String RSAPrivateKey) throws Exception { + public static String decryptBtRsaPriKey(String str,String RSAPrivateKey){ RSA rsa = new RSA(RSAPrivateKey, null); byte[] decrypt = rsa.decrypt(str, KeyType.PrivateKey); return new String(decrypt); } -} \ No newline at end of file +}