diff options
author | surya-huawei <a.u.surya@huawei.com> | 2017-09-11 16:36:49 +0530 |
---|---|---|
committer | SURYA A U <a.u.surya@huawei.com> | 2017-09-12 03:42:43 +0000 |
commit | 9eb50a48faf45d5f1dc01b1209778c1c1d5ed0ae (patch) | |
tree | 5f14554d80ba9064b4e0badf6ed26948db5e7f20 /dblib/provider/src | |
parent | 717f9f2ad37fea378fca4e5487bc92bf41fade53 (diff) |
Fix Sonar issues
Few major issues in sli/core module
Issue-id: CCSDK-67
Change-Id: Iad65b30a6b27814c1984d8db42d36f8569c5cb3f
Signed-off-by: surya-huawei <a.u.surya@huawei.com>
Diffstat (limited to 'dblib/provider/src')
-rw-r--r-- | dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java index 1729bcec0..ee8ab2f33 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java @@ -92,12 +92,14 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito /* (non-Javadoc) * @see javax.sql.DataSource#getConnection() */ + @Override public Connection getConnection() throws SQLException { return ds.getConnection(); } - public CachedRowSet getData(String statement, ArrayList<Object> arguments) throws SQLException, Throwable + public CachedRowSet getData(String statement, ArrayList<Object> arguments) + throws SQLException, Throwable { TestObject testObject = null; testObject = monitor.registerRequest(); @@ -126,7 +128,8 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito } } - public boolean writeData(String statement, ArrayList<Object> arguments) throws SQLException, Throwable + public boolean writeData(String statement, ArrayList<Object> arguments) + throws SQLException, Throwable { TestObject testObject = null; testObject = monitor.registerRequest(); @@ -155,7 +158,8 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito } } - CachedRowSet executePreparedStatement(Connection conn, String statement, ArrayList<Object> arguments, boolean close) throws SQLException, Throwable + CachedRowSet executePreparedStatement(Connection conn, String statement, + ArrayList<Object> arguments, boolean close) throws SQLException, Throwable { long time = System.currentTimeMillis(); @@ -168,9 +172,10 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito } ResultSet rs = null; + PreparedStatement ps = null; try { data = RowSetProvider.newFactory().createCachedRowSet(); - PreparedStatement ps = conn.prepareStatement(statement); + ps = conn.prepareStatement(statement); if(arguments != null) { for(int i = 0, max = arguments.size(); i < max; i++){ @@ -221,6 +226,13 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito } catch(Exception exc){ } + try { + if (ps != null){ + ps.close(); + } + } catch (Exception exc){ + + } } return data; @@ -296,6 +308,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito /* (non-Javadoc) * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String) */ + @Override public Connection getConnection(String username, String password) throws SQLException { @@ -305,6 +318,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito /* (non-Javadoc) * @see javax.sql.DataSource#getLogWriter() */ + @Override public PrintWriter getLogWriter() throws SQLException { return ds.getLogWriter(); @@ -313,6 +327,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito /* (non-Javadoc) * @see javax.sql.DataSource#getLoginTimeout() */ + @Override public int getLoginTimeout() throws SQLException { return ds.getLoginTimeout(); @@ -321,6 +336,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito /* (non-Javadoc) * @see javax.sql.DataSource#setLogWriter(java.io.PrintWriter) */ + @Override public void setLogWriter(PrintWriter out) throws SQLException { ds.setLogWriter(out); @@ -329,12 +345,14 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito /* (non-Javadoc) * @see javax.sql.DataSource#setLoginTimeout(int) */ + @Override public void setLoginTimeout(int seconds) throws SQLException { ds.setLoginTimeout(seconds); } + @Override public final String getDbConnectionName(){ return connectionName; } @@ -418,10 +436,12 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito return true; } + @Override public boolean isWrapperFor(Class<?> iface) throws SQLException { return false; } + @Override public <T> T unwrap(Class<T> iface) throws SQLException { return null; } @@ -445,34 +465,42 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito monitor.deleteObserver(observer); } + @Override public long getInterval() { return interval; } + @Override public long getInitialDelay() { return initialDelay; } + @Override public void setInterval(long value) { interval = value; } + @Override public void setInitialDelay(long value) { initialDelay = value; } + @Override public long getExpectedCompletionTime() { return expectedCompletionTime; } + @Override public void setExpectedCompletionTime(long value) { expectedCompletionTime = value; } + @Override public long getUnprocessedFailoverThreshold() { return unprocessedFailoverThreshold; } + @Override public void setUnprocessedFailoverThreshold(long value) { this.unprocessedFailoverThreshold = value; } @@ -485,6 +513,7 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito canTakeOffLine = false; final Thread offLineTimer = new Thread() { + @Override public void run(){ try { Thread.sleep(30000L); |