diff options
Diffstat (limited to 'ecomp-sdk')
-rw-r--r-- | ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RoleServiceImpl.java | 23 |
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); - } } } |