If efficiently is only related to reading, the answer regarding fetch size is the way to go. If you ran the Java program on the database host (=> localhost connection), it would give you a performance boost.
If efficiently applies to processing as well, do as much as possible in your SQL query. We have run measurements, a RDBMS outperforms Java. For example, filtering and sorting takes longer in Java. It's just makes no sense to re-implement database functionality in Java again, and it's slower.
If your algorithm is not easy to implement using a SQL query, do additional (procedural) processing in a stored procedure, write it completely as a stored procedure or use a stored function in your SQL query. Using stored functions with a SQL query is a really powerful and fast combination.
Your Java client just reads the results, and writes them directly to disk. No buffering, no processing, just I/O.
If you were using Oracle, PostgreSql or DB2, you could even write the stored procedures/functions in Java.