From b25438097e8be54738f9e6cde48e9c4a75103853 Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Fri, 18 Dec 2015 23:26:01 +0530 Subject: [PATCH] Fixed issues in EnrollmentDAOImpl --- .../carbon/device/mgt/core/dao/impl/EnrollmentDAOImpl.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/EnrollmentDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/EnrollmentDAOImpl.java index 61e99798023..f3a5a585117 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/EnrollmentDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/EnrollmentDAOImpl.java @@ -71,7 +71,6 @@ public class EnrollmentDAOImpl implements EnrollmentDAO { PreparedStatement stmt = null; ResultSet rs = null; int status = -1; - int rows; try { conn = this.getConnection(); String sql = "UPDATE DM_ENROLMENT SET OWNERSHIP = ?, STATUS = ?, " + @@ -86,12 +85,12 @@ public class EnrollmentDAOImpl implements EnrollmentDAO { stmt.setString(6, enrolmentInfo.getOwner()); stmt.setInt(7, tenantId); stmt.setInt(8, enrolmentInfo.getId()); - rows = stmt.executeUpdate(); + stmt.executeUpdate(); - if (rows > 0) { + rs = stmt.getGeneratedKeys(); + if (rs.next()) { status = 1; } - return status; } catch (SQLException e) { throw new DeviceManagementDAOException("Error occurred while updating enrolment configuration", e);