X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=datarouter-prov%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fprovisioning%2Fbeans%2FFeed.java;h=a2076b0427b716d40ca62dd6649d8939265a3695;hb=ee6fa61e2cd7df99891092709765235b6166a041;hp=c08bce57b59f2cbb6d3a12537cdf8bbc0600db99;hpb=079a007f29994785912ca891c58e09f755189e58;p=dmaap%2Fdatarouter.git diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java index c08bce57..a2076b04 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/Feed.java @@ -72,8 +72,9 @@ public class Feed extends Syncable { try { DB db = new DB(); Connection conn = db.getConnection(); - try(Statement stmt = conn.createStatement()) { - try(ResultSet rs = stmt.executeQuery("select COUNT(*) from FEEDS where FEEDID = " + id)) { + try(PreparedStatement stmt = conn.prepareStatement("select COUNT(*) from FEEDS where FEEDID = ?")) { + stmt.setInt(1, id); + try(ResultSet rs = stmt.executeQuery()) { if (rs.next()) { count = rs.getInt(1); } @@ -81,7 +82,7 @@ public class Feed extends Syncable { } db.release(conn); } catch (SQLException e) { - e.printStackTrace(); + intlogger.error("SQLException " + e.getMessage()); } return count != 0; } @@ -132,7 +133,7 @@ public class Feed extends Syncable { db.release(conn); } catch (SQLException e) { intlogger.info("countActiveFeeds: " + e.getMessage()); - e.printStackTrace(); + intlogger.error("SQLException " + e.getMessage()); } return count; } @@ -153,7 +154,7 @@ public class Feed extends Syncable { db.release(conn); } catch (SQLException e) { intlogger.info("getMaxFeedID: " + e.getMessage()); - e.printStackTrace(); + intlogger.error("SQLException " + e.getMessage()); } return max; } @@ -199,7 +200,7 @@ public class Feed extends Syncable { } db.release(conn); } catch (SQLException e) { - e.printStackTrace(); + intlogger.error("SQLException " + e.getMessage()); } return map.values(); } @@ -233,7 +234,7 @@ public class Feed extends Syncable { } db.release(conn); } catch (SQLException e) { - e.printStackTrace(); + intlogger.error("SQLException " + e.getMessage()); } return list; } @@ -270,7 +271,7 @@ public class Feed extends Syncable { } db.release(conn); } catch (SQLException e) { - e.printStackTrace(); + intlogger.error("SQLException " + e.getMessage()); } return feed; } @@ -319,7 +320,7 @@ public class Feed extends Syncable { public Feed(JSONObject jo) throws InvalidObjectException { this("", "", "", ""); try { - // The JSONObject is assumed to contain a vnd.att-dr.feed representation + // The JSONObject is assumed to contain a vnd.dmaap-dr.feed representation this.feedid = jo.optInt("feedid", -1); this.groupid = jo.optInt("groupid"); //New field is added - Groups feature Rally:US708115 - 1610 this.name = jo.getString("name"); @@ -533,14 +534,14 @@ public class Feed extends Syncable { } catch (SQLException e) { rv = false; intlogger.warn("PROV0007 doDelete: " + e.getMessage()); - e.printStackTrace(); + intlogger.error("SQLException " + e.getMessage()); } finally { try { if(ps!=null) { ps.close(); } } catch (SQLException e) { - e.printStackTrace(); + intlogger.error("SQLException " + e.getMessage()); } } return rv; @@ -601,7 +602,7 @@ public class Feed extends Syncable { } catch (SQLException e) { rv = false; intlogger.warn("PROV0005 doInsert: " + e.getMessage()); - e.printStackTrace(); + intlogger.error("SQLException " + e.getMessage()); } return rv; } @@ -682,13 +683,12 @@ public class Feed extends Syncable { } catch (SQLException e) { rv = false; intlogger.warn("PROV0006 doUpdate: " + e.getMessage()); - e.printStackTrace(); } finally { try { if (ps != null) ps.close(); } catch (SQLException e) { - e.printStackTrace(); + intlogger.error("SQLException " + e.getMessage()); } } return rv; @@ -715,14 +715,13 @@ public class Feed extends Syncable { } catch (SQLException e) { rv = false; intlogger.warn("PROV0006 doUpdate: " + e.getMessage()); - e.printStackTrace(); } finally { try { if(ps!=null) { ps.close(); } } catch (SQLException e) { - e.printStackTrace(); + intlogger.error("SQLException " + e.getMessage()); } } return rv;