stmt = conn.prepareStatement("UPDATE " + getMailItemTableName(folder) + " SET folder_id = ?, mod_metadata = ? WHERE id IN " + suitableNumberOfVariables(itemIDs)); stmt.setInt(1, folder.getId()); stmt.setInt(2, mbox.getOperationChangeID()); for (int i = 0; i < itemIDs.length; i++) stmt.setInt(i + 3, itemIDs.array[i]);
int attr = 1; if (item instanceof Folder) { stmt = conn.prepareStatement("UPDATE " + getMailItemTableName(item) + " SET parent_id = ?, folder_id = ?, mod_metadata = ?, change_date = ? WHERE id = ?"); stmt.setInt(attr++, folder.getId()); } else if (item instanceof Conversation && !(item instanceof VirtualConversation)) stmt = conn.prepareStatement("UPDATE " + getMailItemTableName(item) + " SET folder_id = ?, mod_metadata = ?, change_date = ? WHERE parent_id = ?"); else stmt = conn.prepareStatement("UPDATE " + getMailItemTableName(item) + " SET folder_id = ?, mod_metadata = ?, change_date = ? WHERE id = ?"); stmt.setInt(attr++, folder.getId()); stmt.setInt(attr++, mbox.getOperationChangeID()); stmt.setInt(attr++, mbox.getOperationTimestamp()); stmt.setInt(attr++, item instanceof VirtualConversation ? ((VirtualConversation) item).getMessageId() : item.getId());
    public static void setFolder(MailItem.Array itemIDs, Folder folder) throws ServiceException {        Mailbox mbox = folder.getMailbox();        Connection conn = mbox.getOperationConnection();        PreparedStatement stmt = null;        try {            stmt = conn.prepareStatement("UPDATE " + getMailItemTableName(folder) +                    " SET folder_id = ?, mod_metadata = ? WHERE id IN " + suitableNumberOfVariables(itemIDs));            stmt.setInt(1, folder.getId());            stmt.setInt(2, mbox.getOperationChangeID());            for (int i = 0; i < itemIDs.length; i++)                stmt.setInt(i + 3, itemIDs.array[i]);            stmt.executeUpdate();        } catch (SQLException e) {            throw ServiceException.FAILURE("writing new folder data for item [" + itemIDs + ']', e);        } finally {            DbPool.closeStatement(stmt);        }    }