By default, the JDBC driver collects all the results for a query at one time. As a result, when you attempt to retrieve a large result set over a JDBC connection, you might encounter a client-side out-of-memory error. To enable your client to retrieve result sets in batches instead of in a single all-or-nothing fetch, set the JDBC fetch size parameter in your client application.
To set the fetch size in DbVisualizer, open the Properties tab for the connection and select Driver Properties. Add a property named java.sql.statement.setFetchSize and set it to a positive value, e.g. 1000, click OK and then re-connect.
If you still run out of memory, try with a lower values.