From f30f3ac37bac4d170e1fe6d87fdf57adb3b783d3 Mon Sep 17 00:00:00 2001 From: konbai <1527468660@qq.com> Date: Fri, 18 Mar 2022 01:37:04 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=E6=89=A7=E8=A1=8C"?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=BD=93=E5=89=8D=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B"=E5=90=8E=E6=9C=AA=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E9=93=BE=E6=8E=A5=EF=BC=8C=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E5=BD=93=E5=89=8D=E8=BF=9E=E6=8E=A5=E6=B1=A0=E4=B8=AD?= =?UTF-8?q?=E6=B4=BB=E8=B7=83=E8=BF=9E=E6=8E=A5=E6=95=B0=E8=BE=BE=E5=88=B0?= =?UTF-8?q?=E6=9C=80=E5=A4=A7=E8=BF=9E=E6=8E=A5=E6=95=B0=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ruoyi/common/helper/DataBaseHelper.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/helper/DataBaseHelper.java b/ruoyi-common/src/main/java/com/ruoyi/common/helper/DataBaseHelper.java index c1adea31..34afa5b8 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/helper/DataBaseHelper.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/helper/DataBaseHelper.java @@ -9,6 +9,7 @@ import lombok.AccessLevel; import lombok.NoArgsConstructor; import javax.sql.DataSource; +import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.SQLException; @@ -26,8 +27,8 @@ public class DataBaseHelper { public static DataBaseType getDataBaseType() { DynamicRoutingDataSource ds = (DynamicRoutingDataSource) SpringUtils.getBean(DataSource.class); DataSource dataSource = ds.determineDataSource(); - try { - DatabaseMetaData metaData = dataSource.getConnection().getMetaData(); + try (Connection conn = dataSource.getConnection()) { + DatabaseMetaData metaData = conn.getMetaData(); String databaseProductName = metaData.getDatabaseProductName(); return DataBaseType.find(databaseProductName); } catch (SQLException e) {