X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=datarouter-prov%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fprovisioning%2Fbeans%2FEgressRoute.java;h=832b8edc839a5b40f9431b5925a15bdc6f7bcf14;hb=85b8739b9f1ebdf9731b134ac2b2796c0e2e5178;hp=242c1053e54145715cb19c6cf7768f04308d956b;hpb=b8fd2c7f6d9def16811fa95549081bc6cdbbf38c;p=dmaap%2Fdatarouter.git diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java index 242c1053..832b8edc 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRoute.java @@ -44,13 +44,14 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB; * @version $Id: EgressRoute.java,v 1.3 2013/12/16 20:30:23 eby Exp $ */ public class EgressRoute extends NodeClass implements Comparable { + private static Logger intlogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal"); private final int subid; private final int nodeid; /** - * Get a set of all Egress Routes in the DB. The set is sorted according to the natural sorting order - * of the routes (based on the subscription ID in each route). + * Get a set of all Egress Routes in the DB. The set is sorted according to the natural sorting order of the routes + * (based on the subscription ID in each route). * * @return the sorted set */ @@ -60,15 +61,15 @@ public class EgressRoute extends NodeClass implements Comparable { DB db = new DB(); @SuppressWarnings("resource") Connection conn = db.getConnection(); - try( Statement stmt = conn.createStatement()) { - try(ResultSet rs = stmt.executeQuery("select SUBID, NODEID from EGRESS_ROUTES")) { - while (rs.next()) { - int subid = rs.getInt("SUBID"); - int nodeid = rs.getInt("NODEID"); - set.add(new EgressRoute(subid, nodeid)); - } - } - } + try (Statement stmt = conn.createStatement()) { + try (ResultSet rs = stmt.executeQuery("select SUBID, NODEID from EGRESS_ROUTES")) { + while (rs.next()) { + int subid = rs.getInt("SUBID"); + int nodeid = rs.getInt("NODEID"); + set.add(new EgressRoute(subid, nodeid)); + } + } + } db.release(conn); } catch (SQLException e) { @@ -93,7 +94,7 @@ public class EgressRoute extends NodeClass implements Comparable { String sql = "select NODEID from EGRESS_ROUTES where SUBID = ?"; ps = conn.prepareStatement(sql); ps.setInt(1, sub); - try(ResultSet rs = ps.executeQuery()) { + try (ResultSet rs = ps.executeQuery()) { if (rs.next()) { int node = rs.getInt("NODEID"); v = new EgressRoute(sub, node); @@ -105,7 +106,7 @@ public class EgressRoute extends NodeClass implements Comparable { intlogger.error("SQLException " + e.getMessage()); } finally { try { - if(ps!=null) { + if (ps != null) { ps.close(); } } catch (SQLException e) { @@ -143,7 +144,7 @@ public class EgressRoute extends NodeClass implements Comparable { intlogger.error("SQLException " + e.getMessage()); } finally { try { - if(ps!=null) { + if (ps != null) { ps.close(); } } catch (SQLException e) { @@ -168,10 +169,9 @@ public class EgressRoute extends NodeClass implements Comparable { rv = true; } catch (SQLException e) { intlogger.warn("PROV0005 doInsert: " + e.getMessage()); - intlogger.error("SQLException " + e.getMessage()); } finally { try { - if(ps!=null) { + if (ps != null) { ps.close(); } } catch (SQLException e) { @@ -194,10 +194,9 @@ public class EgressRoute extends NodeClass implements Comparable { } catch (SQLException e) { rv = false; intlogger.warn("PROV0006 doUpdate: " + e.getMessage()); - intlogger.error("SQLException " + e.getMessage()); } finally { try { - if(ps!=null) { + if (ps != null) { ps.close(); } } catch (SQLException e) { @@ -221,8 +220,9 @@ public class EgressRoute extends NodeClass implements Comparable { @Override public boolean equals(Object obj) { - if (!(obj instanceof EgressRoute)) + if (!(obj instanceof EgressRoute)) { return false; + } EgressRoute on = (EgressRoute) obj; return (subid == on.subid) && (nodeid == on.nodeid); }