Bug #2673 SELECT * FROM "very_large_table" causes OutOfMemoryError
Submitted: 8 Feb 2004 5:10 Modified: 11 Nov 2009 2:35
Reporter: Jörg Schubert Email Updates:
Status: Won't fix Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:3.0.10-stable OS:JDK 1.4.2_03
Assigned to: Mark Matthews CPU Architecture:Any

[8 Feb 2004 5:10] Jörg Schubert
Description:
a SELECT * FROM "very_large_table" causes java.lang.OutOfMemoryError

Statement.fetchSize seems to me ignored.

How to repeat:
		Statement st = con.createStatement();
		ResultSet rs = st.executeQuery("SELECT * FROM very_large_table");

Suggested fix:
Statement.setFetchSize() seems to be ignored.
[8 Feb 2004 5:36] Jörg Schubert
After a bit debugging I found that:

st.setFetchSize(Integer.MIN_VALUE);

works for me.

So It's more a "nice to have"
[8 Feb 2004 9:43] Mark Matthews
Connector/J can't implement setFetchSize() until MySQL supports cursors from the client side (currently, only server-side cursors are supported in MySQL-5.0).
[21 Jan 2005 8:07] Alexis Kinsella
Ok, I have the same problem, and I use the following code: 

stmt = c.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(Integer.MIN_VALUE);

But it is a really big problem for me, I am doing a kind of SQLManager grid in my application to show the result of a query, but how to do to save memory, if forward and backward cursor does not work? I have to load all the data in a local arraylist that contains all rows! and the result is an outofmemoryexception if the table is to big!
even with jdbc drivers of sqlserver I can use cursor to bind data into the grid, so I don't have to load all the data in List! I just have to position the cursor when I want to show a line in the grid that is corresponding to the record!

Is there a nicer way I don't know to do that, please :'(

can MaxDB and jdbc driver work better (if this is the case, is there tools to manage MaxDb?)
[11 Aug 2006 22:10] Jeramyn Feucht
Any ideas on when client side cursors are targeted for support?  This bug is currently preventing us from offering MYSql as a solution for our clients.