|
|
@ -66,11 +66,11 @@ public class DeviceDAOImpl implements DeviceDAO {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int updateDevice(int typeId, Device device, int tenantId) throws DeviceManagementDAOException {
|
|
|
|
public boolean updateDevice(int typeId, Device device, int tenantId) throws DeviceManagementDAOException {
|
|
|
|
Connection conn;
|
|
|
|
Connection conn;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
ResultSet rs = null;
|
|
|
|
boolean status = false;
|
|
|
|
int deviceId = -1;
|
|
|
|
int rows;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String sql = "UPDATE DM_DEVICE SET DESCRIPTION = ?, NAME = ? WHERE DEVICE_IDENTIFICATION = ? AND " +
|
|
|
|
String sql = "UPDATE DM_DEVICE SET DESCRIPTION = ?, NAME = ? WHERE DEVICE_IDENTIFICATION = ? AND " +
|
|
|
@ -81,18 +81,16 @@ public class DeviceDAOImpl implements DeviceDAO {
|
|
|
|
stmt.setString(3, device.getDeviceIdentifier());
|
|
|
|
stmt.setString(3, device.getDeviceIdentifier());
|
|
|
|
stmt.setInt(4, typeId);
|
|
|
|
stmt.setInt(4, typeId);
|
|
|
|
stmt.setInt(5, tenantId);
|
|
|
|
stmt.setInt(5, tenantId);
|
|
|
|
stmt.executeUpdate();
|
|
|
|
rows = stmt.executeUpdate();
|
|
|
|
|
|
|
|
if (rows > 0) {
|
|
|
|
rs = stmt.getGeneratedKeys();
|
|
|
|
status = true;
|
|
|
|
if (rs.next()) {
|
|
|
|
|
|
|
|
deviceId = rs.getInt(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return deviceId;
|
|
|
|
return status;
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while enrolling device '" +
|
|
|
|
throw new DeviceManagementDAOException("Error occurred while enrolling device '" +
|
|
|
|
device.getName() + "'", e);
|
|
|
|
device.getName() + "'", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
|
|
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|