我正在尝试从表中获取数百万数据,并且我正在使用 Java Play Framework 2.0,但存在一些问题。当我对查询设置限制时,它运行良好,如果我请求所有数据,它会抛出错误,例如
Exception in thread "pool-3-thread-1" java.lang.OutOfMemoryError: Java heap space
有人可以帮我吗?
最佳答案
引用手册:
By default the driver collects all the results for the query at once. This can be inconvenient for large data sets so the JDBC driver provides a means of basing a ResultSet on a database cursor and only fetching a small number of rows
(强调我的)
该手册详细描述了如何配置驱动程序以不将所有内容加载到内存中:
http://jdbc.postgresql.org/documentation/head/query.html#query-with-cursor
关于java - 如何使用 JDBC 和 PostgreSQL 获取大数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16060703/