summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-core
diff options
context:
space:
mode:
authorArindam Mondal <arind.mondal@samsung.com>2018-07-16 16:20:27 +0900
committerONAP <arind.mondal@samsung.com>2018-08-03 10:05:16 +0900
commit14f57f705068c0aa1c417eed93274e98226b00ab (patch)
treeff3701fff36504cee2f7a1021f06fde5fd2c665e /ecomp-sdk/epsdk-core
parenta96a3e49cd472aa902c22143358b87562603d47c (diff)
Sonar issue try-with-resources
Modified RoleServiceImpl, replaced Statement with PreparedStatemnent Issue-ID: PORTAL-338 Change-Id: I8d94682abf72080bc63d0e5b6c91e1869629bbc9 Signed-off-by: Arindam Mondal <arind.mondal@samsung.com>
Diffstat (limited to 'ecomp-sdk/epsdk-core')
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RoleServiceImpl.java23
1 files changed, 7 insertions, 16 deletions
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RoleServiceImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RoleServiceImpl.java
index 43cac076..d2d35ef5 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RoleServiceImpl.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RoleServiceImpl.java
@@ -38,6 +38,7 @@
package org.onap.portalsdk.core.service;
import java.sql.Connection;
+import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Iterator;
@@ -166,24 +167,14 @@ public class RoleServiceImpl implements RoleService {
@Override
public void deleteDependcyRoleRecord(String loginId, Long id) {
- Connection conn = null;
- Statement stmt = null;
- try {
- conn = getDataSource().getConnection();
- stmt = conn.createStatement();
- String sql = "delete from fn_user_role where role_id = '" + id + "'";
- stmt.executeUpdate(sql);
+
+ String sql = "delete from fn_user_role where role_id =?";
+ try( Connection conn = getDataSource().getConnection();PreparedStatement pstmt = conn.prepareStatement(sql)) {
+ pstmt.setLong(1, id);
+ pstmt.executeUpdate(sql);
+
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "deleteDependcyRoleRecord failed", e);
- } finally {
- try {
- if (stmt != null)
- stmt.close();
- if (conn != null)
- conn.close();
- } catch (SQLException se) {
- logger.error(EELFLoggerDelegate.errorLogger, "deleteDependcyRoleRecord failed to close", se);
- }
}
}