首先是看Java JDBC的API查看setFetchSize:
查看的结果给出这里的rows只是一个hint,那么对于MySQL JDBC来说是如何实现的呢?useCursorFetchIf connected to MySQL > 5.0.2, and setFetchSize() > 0 on a statement, should that statement use cursor-based fetching to retrieve rows?false
又说是experiment,又说是hint可能被ignore,到底支持还不不支持呢?并且官方文档给出的这个参数没说到底是不是会忽略掉fetchSize.按照故事的尿性来说我该看MySQL JDBC的源码了:
1.首先判断是否可以进行cursor readif(this.connection.versionMeetsMinimum(5, 0, 2)&& this.connection.getUseCursorFetch()&& isBinaryEncoded&& callingStatement != null&& callingStatement.getFetchSize() != 0&& callingStatement.getResultSetType() == ResultSet.TYPE_FORWARD_ONLY)若OK,则RowData rows = new RowDataCursor
2.如果不满足,则判断是否可以进行Streaming Read:
If(this.&& (this.resultSetConcurrency == java.sql.ResultSet.CONCUR_READ_ONLY) && (this.fetchSize =