MATLAB: Do I receive a “java.lang​.OutOfMemo​ryError: Java heap space” error after upgrading to Database Toolbox 3.5.1 (R2009a)

Database Toolbox

After upgrading to Database Toolbox 3.5.1 (R2009a) I receive the following error when executing a query:
??? Java exception occurred:
java.lang.OutOfMemoryError: Java heap space
at oracle.jdbc.driver.OracleStatement.prepareAccessors(OracleStatement.java:796)
at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:949)
at oracle.jdbc.driver.T4CStatement.execute_maybe_describe(T4CStatement.java:463)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1037)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1183)
at com.mathworks.toolbox.database.sqlExec.executeTheSelectStatement(sqlExec.java:170)
Error in ==> cursor.cursor at 150
resultSetVector = executeTheSelectStatement(curs.Cursor,curs.Statement);
Error in ==> database.exec at 34
curs=cursor(connect,sqlQuery);
In previous versions of the toolbox I never received this error.
Now I read that I can increase the Java heap space to prevent similar out of memory errors but I did not have to do this in the previous version. Also, the query which I execute does not operate on a large dataset.

Best Answer

In Database Toolbox 3.5.1 (R2009a) the default value of the JDBC property 'defaultRowPrefetch' was changed from 10 to 10000. This change should increase the performance of the toolbox, however it will also increase the memory requirements of the toolbox.
To prevent the out of memory error from occuring, you can change this property back to its default value; below instructions for this are given for different versions of the toolbox:
To change the property in Database Toolbox 3.5.1 (R2009a):
After creating the connection:
conn = database(....);
Run the following code:
h = conn.Handle;
h.setDefaultRowPrefetch(10);
To change the property in Database Toolbox 3.6 (R2009b):
Run the following code:
setdbprefs('DefaultRowPrefetch','10')
Related Question