public static List listByFolder(Folder folder, byte type, boolean descending) throws ServiceException { Mailbox mbox = folder.getMailbox(); Connection conn = mbox.getOperationConnection();  ArrayList result = new ArrayList(); PreparedStatement stmt = null; ResultSet rs = null; try { stmt = conn.prepareStatement("SELECT id, index_id, type, date FROM " + getMailItemTableName(folder) + " WHERE type = ? AND folder_id = ?" + " ORDER BY date" + (descending ? " DESC" : "")); stmt.setByte(1, type); stmt.setInt(2, folder.getId()); rs = stmt.executeQuery(); while (rs.next()) result.add(SearchResult.createResult(rs, SORT_BY_DATE)); return result; } catch (SQLException e) { throw ServiceException.FAILURE("fetching item list for folder " + folder.getId(), e); } finally { DbPool.closeResults(rs); DbPool.closeStatement(stmt); }
public static List listByFolder(Folder folder, byte type) throws ServiceException { return listByFolder(folder, type, true);
    public static List listByFolder(Folder folder, byte type, boolean descending) throws ServiceException {        Mailbox mbox = folder.getMailbox();        Connection conn = mbox.getOperationConnection();        ArrayList result = new ArrayList();        PreparedStatement stmt = null;        ResultSet rs = null;        try {            stmt = conn.prepareStatement("SELECT id, index_id, type, date FROM " + getMailItemTableName(folder) +                    " WHERE type = ? AND folder_id = ?" +            		" ORDER BY date" + (descending ? " DESC" : ""));            stmt.setByte(1, type);            stmt.setInt(2, folder.getId());            rs = stmt.executeQuery();            while (rs.next())            	result.add(SearchResult.createResult(rs, SORT_BY_DATE));            return result;        } catch (SQLException e) {        	throw ServiceException.FAILURE("fetching item list for folder " + folder.getId(), e);        } finally {        	DbPool.closeResults(rs);            DbPool.closeStatement(stmt);        }    }