Normally when I want to query large result set using Mysql I write this (taken from this answer):
stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(Integer.MIN_VALUE);
Now I’m using jOOQ 2.0.5 and I can’t achieve the same result.
I’ve tried calling fetchLazy with no luck, it loads the entire result set in memory:
Cursor<Record> result = query.fetchLazy(Integer.MIN_VALUE);
As a workaround I can get the sql query using query.getSQL() and create a suitable Statement to execute it.
Is there another way to have stream result sets using jOOQ?
According to the JDBC specs,
Integer.MIN_VALUEis not a valid argument for theStatement.setFetchSize()method:Implementations may throw a
SQLExceptionfor negative fetch sizes. Hence, jOOQ doesn’t accept parameters less than 0. You should try using a fetch size of1instead. In the mean time, the next release of jOOQ might be able to break the JDBC standard, to support this documented MySQL feature:
https://github.com/jOOQ/jOOQ/issues/1263 (implemented in jOOQ 2.2.0)