X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=datarouter-prov%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fprovisioning%2FStatisticsServlet.java;h=33bf3a35274d18154802c0e822659264b8ae354c;hb=ecc28463e0e98cab52e8b71df912cbfeac55c23e;hp=e79d47052497760726825449d740bebcc68f6148;hpb=a1cc0279360b09663c1b59fd0b89a1c2e081dfbd;p=dmaap%2Fdatarouter.git diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java index e79d4705..33bf3a35 100755 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java @@ -569,40 +569,17 @@ public class StatisticsServlet extends BaseServlet { intlogger.debug(sql); long start = System.currentTimeMillis(); DB db = new DB(); - Connection conn = null; ResultSet rs = null; - Statement stmt = null; - PreparedStatement pst = null; - try { - conn = db.getConnection(); - stmt = conn.createStatement(); - pst = conn.prepareStatement(sql); - rs = pst.executeQuery(); + try ( + Connection conn = db.getConnection()){ + try(PreparedStatement pst = conn.prepareStatement(sql)){ + rs = pst.executeQuery(); + } } catch (SQLException e) { e.printStackTrace(); - } finally { - - try { - if (conn != null) { - db.release(conn); - } - if (stmt != null) { - stmt.close(); - } - if (pst != null) { - pst.close(); - } - if (rs != null) { - rs.close(); - } - - } catch (SQLException sqlException) { - intlogger.error("Exception in getting SQl Records",sqlException); - } - + } intlogger.debug("Time: " + (System.currentTimeMillis() - start) + " ms"); - return rs; } } -} +