Out of Memory Error when using huge datasets

  • Share
  • Share

Applies to:
NA

Description:
Occurs while using huge result sets.

Cause:
You have tried to use huge result set, for instance, more than with 100,000 rows.

JAVA-JDBC , , , , , ,

  1. admin
    March 20th, 2009 at 10:28 | #1

    The best way to fix this problem is to not SELECT so many rows at one time. Use WHERE and/or HAVING and/or LIMIT type clauses to restrict the number of rows you return at one time. For a robust JDBC driver, Statement.setMaxRows(int max) can limit it too.
    If you need to page data then you should also do that with the use of better SQL rather than seeking a Java only solution.
    A further solution is often to change the scrolling type of your ResultSet? cursor to be type forward. Due to to the way many drivers implement scrolling in ResultSets? these types of Cursors can be very expensive.

  1. No trackbacks yet.