intlogger.debug(sql);\r
long start = System.currentTimeMillis();\r
DB db = new DB();\r
- Connection conn = null;\r
ResultSet rs = 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
- } 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
+ }\r
intlogger.debug("Time: " + (System.currentTimeMillis() - start) + " ms");\r
-\r
return rs;\r
}\r
}\r
-}\r
+\r