Why do I receive a "java.lang.OutOfMemoryError: Java heap space" error after upgrading to Database Toolbox 3.5.1 (R2009a)?
2 views (last 30 days)
Show older comments
MathWorks Support Team
on 23 Oct 2009
Edited: MathWorks Support Team
on 11 May 2023
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.
Accepted Answer
MathWorks Support Team
on 23 Oct 2009
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')
1 Comment
Usha Duddu
on 18 Mar 2016
Edited: MathWorks Support Team
on 11 May 2023
Hi Eric LePage
I understand you are running into "java.lang.OutOfMemoryError: Java heap space Exception in thread "AWT-EventQueue-0" error when executing a database query.
Are you getting the errors after following the suggested workaround on Database Toolbox of R2009a?
Please contact MathWorks Technical Support and raise a help ticket. I am sure our team will be very happy to help you.
Thank you
Usha
More Answers (0)
See Also
Categories
Find more on Database Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!