summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java37
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 1729bcec..ee8ab2f3 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);