@Override public void deleteOperation(int operationId) throws OperationManagementDAOException { PreparedStatement stmt = null; try { super.deleteOperation(operationId); Connection connection = OperationManagementDAOFactory.getConnection(); stmt = connection.prepareStatement("DELETE DM_POLICY_OPERATION WHERE OPERATION_ID=?"); stmt.setInt(1, operationId); stmt.executeUpdate(); } catch (SQLException e) { throw new OperationManagementDAOException( "Error occurred while deleting operation metadata", e); } finally { OperationManagementDAOUtil.cleanupResources(stmt); } }
@Override public void updateOperation(Operation operation) throws OperationManagementDAOException { PreparedStatement stmt = null; ByteArrayOutputStream bao = null; ObjectOutputStream oos = null; try { super.updateOperation(operation); Connection connection = OperationManagementDAOFactory.getConnection(); stmt = connection.prepareStatement( "UPDATE DM_POLICY_OPERATION O SET O.OPERATION_DETAILS=? " + "WHERE O.OPERATION_ID=?"); bao = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bao); oos.writeObject(operation); stmt.setBytes(1, bao.toByteArray()); stmt.setInt(2, operation.getId()); stmt.executeUpdate(); } catch (SQLException e) { throw new OperationManagementDAOException( "Error occurred while update policy operation metadata", e); } catch (IOException e) { throw new OperationManagementDAOException( "Error occurred while serializing policy operation object", e); } finally { if (bao != null) { try { bao.close(); } catch (IOException e) { log.warn("Error occurred while closing ByteArrayOutputStream", e); } } if (oos != null) { try { oos.close(); } catch (IOException e) { log.warn("Error occurred while closing ObjectOutputStream", e); } } OperationManagementDAOUtil.cleanupResources(stmt); } }