https://sonar.onap.org/project/issues?id=org.onap.dmaap.datarouter%3Aparent&open=AWWKm3GexOv3LmQdDLM3&resolved=false&severities=BLOCKER&types=BUG
Issue-ID: DMAAP-694
Change-Id: Ibd5ee6dd784627bc8afa6e26c82e2c2ceb62a9a9
Signed-off-by: Amaresh Kumar <kamaresh@in.ibm.com>
intlogger.debug(sql);\r
long start = System.currentTimeMillis();\r
DB db = new DB();\r
intlogger.debug(sql);\r
long start = System.currentTimeMillis();\r
DB db = new DB();\r
- Connection conn = null;\r
- Statement stmt = null;\r
- PreparedStatement pst = null;\r
- try {\r
- conn = db.getConnection();\r
- stmt = conn.createStatement();\r
- pst = conn.prepareStatement(sql);\r
- rs = pst.executeQuery();\r
+ try (\r
+ Connection conn = db.getConnection()){\r
+ try(PreparedStatement pst = conn.prepareStatement(sql)){\r
+ rs = pst.executeQuery();\r
+ }\r
} catch (SQLException e) {\r
e.printStackTrace();\r
} catch (SQLException e) {\r
e.printStackTrace();\r
- } finally {\r
-\r
- try {\r
- if (conn != null) {\r
- db.release(conn);\r
- }\r
- if (stmt != null) {\r
- stmt.close();\r
- }\r
- if (pst != null) {\r
- pst.close();\r
- }\r
- if (rs != null) {\r
- rs.close();\r
- }\r
-\r
- } catch (SQLException sqlException) {\r
- intlogger.error("Exception in getting SQl Records",sqlException);\r
- }\r
-\r
intlogger.debug("Time: " + (System.currentTimeMillis() - start) + " ms");\r
intlogger.debug("Time: " + (System.currentTimeMillis() - start) + " ms");\r