Exception in thread “main” java.lang.OutOfMemoryError: Java heap space
Just wanted to create a simple Loop with JDBC/MySQL that will read a big database table and proces the data.
Unfortunately the “Java heap space” error occured.
The following solution worked though:
stmt = con.createStatement(
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(Integer.MIN_VALUE);
This will tell the driver to step through the resultset instead of loading everything at once.
Tags: Just wanted to create a simple loop that will read all