From 4379232c25a8c26d5b7dd422e6a17e7b33fd9789 Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Mon, 16 Nov 2015 22:01:21 +0530 Subject: [PATCH] Refactored Enrollment DAO class --- .../carbon/device/mgt/core/dao/impl/EnrollmentDAOImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 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 f3a5a58511..61e9979802 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,6 +71,7 @@ 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 = ?, " + @@ -85,12 +86,12 @@ public class EnrollmentDAOImpl implements EnrollmentDAO { stmt.setString(6, enrolmentInfo.getOwner()); stmt.setInt(7, tenantId); stmt.setInt(8, enrolmentInfo.getId()); - stmt.executeUpdate(); + rows = stmt.executeUpdate(); - rs = stmt.getGeneratedKeys(); - if (rs.next()) { + if (rows > 0) { status = 1; } + return status; } catch (SQLException e) { throw new DeviceManagementDAOException("Error occurred while updating enrolment configuration", e);