summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java30
1 files changed, 15 insertions, 15 deletions
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java
index 1853ee30..70b8e6a0 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecord.java
@@ -59,23 +59,23 @@ public class LogRecord extends BaseLogRecord {
Connection conn = null;
try {
conn = db.getConnection();
- Statement stmt = conn.createStatement();
- Iterator<Long[]> iter = bs.getRangeIterator();
- PreparedStatement ps = conn.prepareStatement(sql);
- while (iter.hasNext()) {
- Long[] n = iter.next();
- ps.setLong(1, n[0]);
- ps.setLong(2, n[1]);
- ResultSet rs = ps.executeQuery();
- while (rs.next()) {
- LogRecord lr = new LogRecord(rs);
- os.write(lr.toString().getBytes());
+ try(Statement stmt = conn.createStatement()) {
+ Iterator<Long[]> iter = bs.getRangeIterator();
+ try(PreparedStatement ps = conn.prepareStatement(sql)) {
+ while (iter.hasNext()) {
+ Long[] n = iter.next();
+ ps.setLong(1, n[0]);
+ ps.setLong(2, n[1]);
+ try(ResultSet rs = ps.executeQuery()) {
+ while (rs.next()) {
+ LogRecord lr = new LogRecord(rs);
+ os.write(lr.toString().getBytes());
+ }
+ ps.clearParameters();
+ }
+ }
}
- rs.close();
- ps.clearParameters();
}
- ps.close();
- stmt.close();
} catch (SQLException e) {
e.printStackTrace();
} finally {