From 34a8641582e18f1bc8953bba9e1a989f1973d9c2 Mon Sep 17 00:00:00 2001 From: Dulitha Wijewantha Date: Sat, 30 May 2015 22:11:43 +0530 Subject: [PATCH] * Added update device implementation --- .../mgt/core/dao/impl/DeviceDAOImpl.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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