Good question. qie.doQuery(), allocates a connection, executes the query, loads the result set into a CSV Message Model, closes the connection, and then returns the CSV Message Model. It handles the proper cleanup of the connections and safely catches any exceptions. As your question implies, this simplified approach is ideal for a controlled number of rows returned from the DB.
For queries that retrieve large binary data fields (blob), or if calling a stored procedure that uses cursors, you can use the qie.getDbConnection(). We have some examples of using the qie.getDbConnection() here.
As a general rule, use the qie.doQuery() and refine your query to limit the number of rows. You can usually call the qie.doQuery() in a while loop to achieve the same result.