aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRam Koya <rk541m@att.com>2018-09-04 13:11:11 +0000
committerGerrit Code Review <gerrit@onap.org>2018-09-04 13:11:11 +0000
commit1fb6824940d14d70f80d7bb2138cd1137b8057be (patch)
tree083e20e37474fe98a4344eff6dd51cf04325d76c
parent38e9612306fdc1453382e3555002663c4a5ed6fd (diff)
parent9e44b46b5fbb760b7b43fb515041512678aa977b (diff)
Merge "ConnWrapper.java: Fixed sonar issue"
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/database/ConnWrapper.java28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/main/java/org/onap/dmaap/dbcapi/database/ConnWrapper.java b/src/main/java/org/onap/dmaap/dbcapi/database/ConnWrapper.java
index e0c7819..2317fe4 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/database/ConnWrapper.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/database/ConnWrapper.java
@@ -22,17 +22,22 @@ package org.onap.dmaap.dbcapi.database;
import java.sql.*;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
public abstract class ConnWrapper<T, U> {
+ EELFLogger logger = EELFManager.getInstance().getLogger( ConnWrapper.class );
protected Connection c;
protected PreparedStatement ps;
protected ResultSet rs;
protected abstract T run(U u) throws Exception;
- public T protect(ConnectionFactory cf, U u) throws DBException {
+ public T protect(ConnectionFactory cf, U u) {
try {
try {
return(attempt(cf, u, false));
} catch (SQLException sqle) {
+ logger.error("Error", sqle);
return(attempt(cf, u, true));
}
} catch (RuntimeException rte) {
@@ -52,11 +57,26 @@ public abstract class ConnWrapper<T, U> {
c = null;
return(ret);
} finally {
- if (rs != null) { try { rs.close(); } catch (Exception e) {}}
+ if (rs != null) {
+ try {
+ rs.close();
+ } catch (Exception e) {
+ logger.error("Error", e);
+ }}
rs = null;
- if (ps != null) { try { ps.close(); } catch (Exception e) {}}
+ if (ps != null) {
+ try {
+ ps.close();
+ } catch (Exception e) {
+ logger.error("Error", e);
+ }}
ps = null;
- if (c != null) { try { c.close(); } catch (Exception e) {}}
+ if (c != null) {
+ try {
+ c.close();
+ } catch (Exception e) {
+ logger.error("Error", e);
+ }}
c = null;
}
}