Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.OutOfMemoryError: Java heap space in DB query

 
Sky Loi
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use Spring JdbcTemplate to do the following query and use RowMapper to get the ResultSet. However, the Jboss server generate java.lang.OutOfMemoryError some time.

SELECT *
FROM transactions
WHERE transaction_id = (SELECT refenence_tran_id FROM transactions WHERE transaction_id = '1234')
or transaction_id = (SELECT original_transaction_id FROM transactions WHERE transaction_id = '1234')
or original_transaction_id = '1234' or refenence_tran_id = '1234' order by transaction_id

Notes:
1. The table transactions is a very big table
2. I have set all index for columns transaction_id, refenence_tran_id and original_transaction_id.
3. The query usually return 2-3 result rows
4. Seems the java.lang.OutOfMemoryError happened in high load

My concern is why there is memory error for this query with just quite a few result sets. Any wrong with my query syntax above? Thank you for your help in advance.



 
Sky Loi
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The whole error log is:

INFO [org.springframework.jdbc.support.SQLErrorCodesFactory] SQLErrorCodes loaded: [DB2, HSQL, MS-SQL, MySQL, Oracle, Informix, PostgreSQL, Sybase]

ERROR [STDERR] com.active.dao.DAOException: An exception occurred during database access: PreparedStatementCallback; uncategorized SQLException for SQL [SELECT * FROM transactions WHERE transaction_id = (SELECT refenence_tran_id FROM transactions WHERE transaction_id = ?) or transaction_id = (SELECT original_transaction_id FROM transactions WHERE transaction_id = ?) or original_transaction_id = ? or refenence_tran_id = ? order by transaction_id]; SQL state [null]; error code [0]; Error; - nested throwable: (java.lang.OutOfMemoryError: Java heap space); nested exception is org.jboss.util.NestedSQLException: Error; - nested throwable: (java.lang.OutOfMemoryError: Java heap space)
.........
 
John Kimball
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a log of the exact query/parameter that runs, when you get an out of memory error?
And what happens if you run the same error-generating query directly, using a SQL querying tool?

Or maybe you have a memory leak somewhere else in the application.

Is this the ONLY place where you get an out of memory error?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic