java JDBC 是否有最大 ResultSet 大小?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26619867/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Does JDBC have a maximum ResultSet size?
提问by sparks
Is there a maximum number of rows that a JDBC will put into a ResultSet specifically from a Hive query? I am not talking about fetch size or paging, but the total number of rows returned in a ResultSet.
JDBC 将专门从 Hive 查询放入 ResultSet 的行数是否有最大限制?我不是在谈论获取大小或分页,而是在 ResultSet 中返回的总行数。
Correct me if I'm wrong, but the fetch size sets the number of rows the jdbc looks at to process with each pass in the database, inserting appropriate responses into the ResultSet. When it has gone through all the records in the table, it returns the ResultSet to the Java code. I am asking if there is a limit to the number of rows returned to the Java code.
如果我错了,请纠正我,但提取大小设置 jdbc 在数据库中每次传递时查看的行数,将适当的响应插入到 ResultSet 中。当它遍历了表中的所有记录时,它会将 ResultSet 返回给 Java 代码。我在问返回给 Java 代码的行数是否有限制。
If it doesn't have a maximum number of rows, is there anything inherent with the class that may cause some records to be trimmed off?
如果它没有最大行数,该类是否有任何固有的东西可能会导致某些记录被修剪掉?
回答by Serge Ballesta
No, it does not work that way. JDBC is just a wrapper around native databases. But either JDBC or database cursors work the same :
不,它不能那样工作。JDBC 只是本机数据库的包装器。但是 JDBC 或数据库游标的工作方式相同:
- you send a query (via JDBC) to the database
- the database analyses the query and initializes the cursor (ResulSet in JDBC)
- while you fetch data from the ResultSet, the databases software walks in the database to get new rows and populates the ResultSet
- 您向数据库发送查询(通过 JDBC)
- 数据库分析查询并初始化游标(JDBC中的ResulSet)
- 当您从 ResultSet 中获取数据时,数据库软件会进入数据库以获取新行并填充 ResultSet
So there is no limit to the number of rows that a ResultSet can contains, nor to the number of rows that a java client program can process. The only limit comes if you try to load all the rows in memory to populate a list for example and exhaust the client application memory. But if you process rows and do not keep them in memory, there is no limit (exactly like what happens when you read a file).
因此,ResultSet 可以包含的行数没有限制,java 客户端程序可以处理的行数也没有限制。例如,如果您尝试加载内存中的所有行以填充列表并耗尽客户端应用程序内存,则会出现唯一的限制。但是,如果您处理行并且不将它们保存在内存中,则没有限制(就像读取文件时发生的情况一样)。