aboutsummaryrefslogtreecommitdiffstats
path: root/datarouter-prov/src/main
diff options
context:
space:
mode:
authorRam Koya <rk541m@att.com>2018-09-04 15:42:46 +0000
committerGerrit Code Review <gerrit@onap.org>2018-09-04 15:42:46 +0000
commit0c1044a2b6a3433d5ca2710f8a425f11966675d7 (patch)
tree149fda37651ec4719569ba8fae395a1e177be4df /datarouter-prov/src/main
parent4a488856e1f47f46785586f8bf3dabbe067f11e7 (diff)
parentecc28463e0e98cab52e8b71df912cbfeac55c23e (diff)
Merge "Added sonar fixes in StatisticsServlet.java"
Diffstat (limited to 'datarouter-prov/src/main')
-rwxr-xr-xdatarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java37
1 files changed, 7 insertions, 30 deletions
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;
}
}
-}
+