diff options
author | Parshad Patel <pars.patel@samsung.com> | 2018-10-26 12:08:45 +0900 |
---|---|---|
committer | Parshad Patel <pars.patel@samsung.com> | 2018-10-26 12:09:02 +0900 |
commit | 97e29f1fe153f283133c560642a9c5fca16c87a0 (patch) | |
tree | 4d54662522e922f99f88f919b58533f20821e8a6 /ecomp-sdk/epsdk-analytics/src/main | |
parent | f1f4032dece61d15ab8d4e8b90168d631073ceb8 (diff) |
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 <pars.patel@samsung.com>
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/main')
-rw-r--r-- | ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/RemDbUtils.java | 17 |
1 files 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 { |