aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2017-04-27 19:03:57 -0400
committerDan Timoney <dtimoney@att.com>2017-04-27 19:08:04 -0400
commit7e0c209c8f74c7af614e4bc0f0d8e0d04c182474 (patch)
treeb79640efcdb06ba754d00ba5d92a73f0965791ba
parenta632cf9550fb4ceb1e1f357d307dfbb94b87f4f1 (diff)
[SONAR] Close prepared statement
Close prepared statement (identified by Sonar) Change-Id: I885049ab924b422dc80ae818fcbb6f31b7a26f99 Signed-off-by: Dan Timoney <dtimoney@att.com>
-rw-r--r--sql-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/sql/SqlResource.java20
1 files changed, 16 insertions, 4 deletions
diff --git a/sql-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/sql/SqlResource.java b/sql-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/sql/SqlResource.java
index 2dc450b..2abf5ab 100644
--- a/sql-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/sql/SqlResource.java
+++ b/sql-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/sql/SqlResource.java
@@ -3,14 +3,14 @@
* openECOMP : SDN-C
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
+ * reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -389,6 +389,7 @@ public class SqlResource implements SvcLogicResource, SvcLogicJavaPlugin {
// If printable, not encrypted
return (strValue);
} else {
+ PreparedStatement stmt = null;
Connection conn = null;
ResultSet results = null;
try {
@@ -399,7 +400,7 @@ public class SqlResource implements SvcLogicResource, SvcLogicJavaPlugin {
// null, null);
conn = ((DBResourceManager) dblibSvc).getConnection();
- PreparedStatement stmt = conn.prepareStatement("SELECT CAST(AES_DECRYPT(?, ?) AS CHAR(50)) FROM DUAL");
+ stmt = conn.prepareStatement("SELECT CAST(AES_DECRYPT(?, ?) AS CHAR(50)) FROM DUAL");
stmt.setBytes(1, colValue);
stmt.setString(2, getCryptKey());
@@ -423,6 +424,16 @@ public class SqlResource implements SvcLogicResource, SvcLogicJavaPlugin {
} catch (Exception exc) {
}
+
+ try {
+ if (stmt != null) {
+ stmt.close();
+ stmt = null;
+ }
+ } catch (Exception exc) {
+
+ }
+
try {
if (conn != null) {
conn.close();
@@ -431,6 +442,7 @@ public class SqlResource implements SvcLogicResource, SvcLogicJavaPlugin {
} catch (Exception exc) {
}
+
}
}
return (strValue);