/**\r
* getFeedIdsByGroupId - Getting FEEDID's by GROUP ID.\r
*\r
- * @throws SQL Query SQLException.\r
+ * @throws SQLException Query SQLException.\r
*/\r
public StringBuffer getFeedIdsByGroupId(int groupIds) throws SQLException {\r
\r
DB db = null;\r
Connection conn = null;\r
- PreparedStatement prepareStatement = null;\r
+ //PreparedStatement prepareStatement = null;\r
ResultSet resultSet = null;\r
String sqlGoupid = null;\r
StringBuffer feedIds = new StringBuffer();\r
db = new DB();\r
conn = db.getConnection();\r
sqlGoupid = " SELECT FEEDID from FEEDS WHERE GROUPID = ?";\r
- prepareStatement = conn.prepareStatement(sqlGoupid);\r
- prepareStatement.setInt(1, groupIds);\r
- resultSet = prepareStatement.executeQuery();\r
- while (resultSet.next()) {\r
- feedIds.append(resultSet.getInt("FEEDID"));\r
- feedIds.append(",");\r
+ try(PreparedStatement prepareStatement = conn.prepareStatement(sqlGoupid)) {\r
+ prepareStatement.setInt(1, groupIds);\r
+ resultSet = prepareStatement.executeQuery();\r
+ while (resultSet.next()) {\r
+ feedIds.append(resultSet.getInt("FEEDID"));\r
+ feedIds.append(",");\r
+ }\r
+ feedIds.deleteCharAt(feedIds.length() - 1);\r
+ System.out.println("feedIds" + feedIds.toString());\r
}\r
- feedIds.deleteCharAt(feedIds.length() - 1);\r
- System.out.println("feedIds" + feedIds.toString());\r
-\r
} catch (SQLException e) {\r
e.printStackTrace();\r
} finally {\r
resultSet.close();\r
resultSet = null;\r
}\r
-\r
- if (prepareStatement != null) {\r
- prepareStatement.close();\r
- prepareStatement = null;\r
- }\r
-\r
- if (conn != null) {\r
+ if (conn != null) {\r
db.release(conn);\r
}\r
} catch (Exception e) {\r
intlogger.info("Error parsing time=" + s);\r
return -1;\r
}\r
-\r
-\r
private ResultSet getRecordsForSQL(String sql) {\r
- intlogger.debug(sql);\r
- long start = System.currentTimeMillis();\r
- DB db = new DB();\r
- Connection conn = null;\r
- ResultSet rs = null;\r
-\r
- try {\r
- conn = db.getConnection();\r
- Statement stmt = conn.createStatement();\r
- PreparedStatement pst = conn.prepareStatement(sql);\r
- rs = pst.executeQuery();\r
- //this.rsToJson(rs)\r
- //rs.close();\r
- stmt.close();\r
- } catch (SQLException e) {\r
- e.printStackTrace();\r
- } finally {\r
- if (conn != null) {\r
- db.release(conn);\r
- }\r
- }\r
+ 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
+ } 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
\r
- return rs;\r
+ return rs;\r
+ }\r
}\r
}\r