From 97e29f1fe153f283133c560642a9c5fca16c87a0 Mon Sep 17 00:00:00 2001 From: Parshad Patel Date: Fri, 26 Oct 2018 12:08:45 +0900 Subject: Fix sonar blocker issue Fix use try with resources issue in RemDbUtils.java Issue-ID: PORTAL-342 Change-Id: Ibbb134ec9686730cc9dadad88ea60c2bd3286938 Signed-off-by: Parshad Patel --- .../org/onap/portalsdk/analytics/system/RemDbUtils.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/RemDbUtils.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/RemDbUtils.java index 3a08edca..8e4def24 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/RemDbUtils.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/RemDbUtils.java @@ -181,19 +181,14 @@ public class RemDbUtils /* implements IDbUtils */{ try { if (con==null || con.isClosed()) con = getConnection(dbKey); if(con==null) throw new ReportSQLException("Remote Connection not configured for "+ dbKey); - Statement stmt = con.createStatement(); - logger.debug(EELFLoggerDelegate.debugLogger, ("[SQL CALL FROM RAPTOR] [SQL] " + sql)); - ResultSet rs = stmt.executeQuery(sql); - DataSet ds = new DataSet(rs, maxRowLimit); - if(rs!=null) - rs.close(); - if(stmt!=null) - stmt.close(); - - return ds; + try(Statement stmt = con.createStatement(); + ResultSet rs = stmt.executeQuery(sql);){ + logger.debug(EELFLoggerDelegate.debugLogger, ("[SQL CALL FROM RAPTOR] [SQL] " + sql)); + return new DataSet(rs, maxRowLimit); + } } catch (SQLException e) { throw new ReportSQLException(e.getMessage(), sql, e.getCause()); - } + } } // executeQuery public static DataSet executeQuery(String sql,String dbKey) throws ReportSQLException { -- cgit 1.2.3-korg