public void dumpQueue(Connection conn, PrintWriter writer)
        throws ServerException {

        logger.info("Preparing queue for processing...");

        Statement stmt = null;
        ResultSet results = null;
        int resultCount = 0;

        try {

            stmt = conn.createStatement();
            results =
                executeQuery(stmt, "SELECT queueKey, identifier, "
                    + "mdPrefix, sourceInfo, queueSource " + "FROM rcQueue "
                    + "ORDER BY queueKey ASC");
            while (results.next()) {
                resultCount++;

                writer.print(results.getInt(1) + " ");

                String identifier = results.getString(2);
                writer.print(identifier + " ");

                String mdPrefix = results.getString(3);
                writer.print(mdPrefix + " ");

                writer.print(results.getString(5) + " ");

                String sourceInfo = DBUtil.getLongString(results, 4);
                if ((sourceInfo.indexOf("\n") != -1)
                    || (sourceInfo.indexOf("\r") != -1)) {
                    throw new ServerException(
                        "rcQueue contains bad sourceInfo for " + identifier
                            + "/" + mdPrefix + " (contains " + "newline(s)): '"
                            + sourceInfo + "'");
                }
                writer.println(sourceInfo);
            }
        }
        catch (SQLException e) {
            throw new ServerException("Failed to dump queue", e);
        }
        finally {
            if (results != null)
                try {
                    results.close();
                }
                catch (Exception ex) {
                }
            if (stmt != null)
                try {
                    stmt.close();
                }
                catch (Exception ex) {
                }

            if (resultCount > 0) {
                // JDBC driver may be using a lot of heap space at this point,
                // so try to convince the VM to clean up after it
                results = null;
                stmt = null;
                System.gc();
            }
        }
    }