-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Roland Carlsson wrote:
Hi! I have a query that returns a resultset of 70 mb. I'd somehow would like J/Connector to fetch only small pieces using Statement.setFetchSize but it still get the whole ResultSet at once and then I get an OutOfMemoryError.
Is it a bug in setFetchSize? Does J/Connector ignore it? Have I totally missunderstood what setFetchSize does?
I use J/Connector 3.0.6
Regards Roland Carlsson
From the README:
If you need to "stream" result sets, row-by-row, the driver now supports this. What you need to do is create a statement in the following manner:
stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(Integer.MIN_VALUE);
This serves as a signal to the driver to "stream" result sets row-by-row. After this any result sets created with the statement will be retrieved row-by-row.
There are some caveats with this approach. You will have to read all of the rows in the result set (or close it) before you can issue any other queries on the connection, or an exception will be thrown. Some of the positioning methods will not work as well, especially ones that require 'knowledge' of the entire result set, like isBeforeFirst(), isAfterLast() (when the result set is empty), absolute(), relative(), isLast() (call .next() and check for a 'false' return value instead). This is because the driver does not know how many rows are going to be returned.
-Mark
- -- MySQL 2003 Users Conference -> http://www.mysql.com/events/uc2003/
For technical support contracts, visit https://order.mysql.com/?ref=mmma
__ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Mark Matthews <[EMAIL PROTECTED]> / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer - JDBC/Java /_/ /_/\_, /___/\___\_\___/ Flossmoor (Chicago), IL USA <___/ www.mysql.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.1.90 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE+beH7tvXNTca6JD8RAoqNAJ9mEjOAfVcK1Cc2ltjR8RW9ylYJBgCgpwUW CQ/E6VZD56TR5eA+pGA0wQQ= =VSZ1 -----END PGP SIGNATURE-----
--------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php