diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java index b471ad342a..c5a194ad54 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java @@ -79,7 +79,23 @@ public class DeviceDAOImpl implements DeviceDAO { @Override public void updateDevice(Device device) throws DeviceManagementDAOException { - + Connection conn = null; + PreparedStatement stmt = null; + try { + conn = this.getConnection(); + String sql = + "UPDATE DM_DEVICE SET STATUS=?, OWNER=? WHERE DEVICE_IDENTIFICATION=?"; + stmt = conn.prepareStatement(sql); + stmt.setString(1, device.getStatus().toString()); + stmt.setString(2, device.getOwnerId()); + stmt.setString(3, device.getDeviceIdentificationId()); + stmt.executeUpdate(); + } catch (SQLException e) { + throw new DeviceManagementDAOException("Error occurred while enrolling device " + + "'" + device.getName() + "'", e); + } finally { + DeviceManagementDAOUtil.cleanupResources(conn, stmt, null); + } } @Override