From 074d6aa77a495f7074778e3f22fcd10b7ce3d3df Mon Sep 17 00:00:00 2001 From: hxy1991 Date: Tue, 9 Oct 2018 20:23:33 +0800 Subject: [PATCH] Fix #119 --- .../service/LocalDataSourceServiceImpl.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/LocalDataSourceServiceImpl.java b/config/src/main/java/com/alibaba/nacos/config/server/service/LocalDataSourceServiceImpl.java index 527ce5503..cc650b242 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/LocalDataSourceServiceImpl.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/LocalDataSourceServiceImpl.java @@ -178,19 +178,23 @@ public class LocalDataSourceServiceImpl implements DataSourceService { * @param sqlFile sql * @throws Exception Exception */ - public void execute(Connection conn, String sqlFile) throws Exception { + private void execute(Connection conn, String sqlFile) throws Exception { Statement stmt = null; - List sqlList = loadSql(sqlFile); - stmt = conn.createStatement(); - for (String sql : sqlList) { - try { - stmt.execute(sql); - } catch (Exception e) { - LogUtil.defaultLog.info(e.getMessage()); + try { + List sqlList = loadSql(sqlFile); + stmt = conn.createStatement(); + for (String sql : sqlList) { + try { + stmt.execute(sql); + } catch (Exception e) { + LogUtil.defaultLog.info(e.getMessage()); + } + } + } finally { + if (stmt != null) { + stmt.close(); } - } - stmt.close(); } public static String getAppHome() {