0

我正在尝试从本地安装的 PostgreSQL 10.3 中的一张表中读取其中一列

Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/vk", "postgres", "qwerty");
Statement statement = conn.createStatement();
statement.setFetchSize(10);
ResultSet rs = statement.executeQuery("select POST_CONTENT from VK_GROUP_POST");
System.out.println("rs is ready " + rs);

我运行带有-verbose:gc -Xmx512MVM 选项的程序。项目只有依赖:org.postgresql:postgresql:42.2.1

而且我总是收到OOM错误:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
...
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2134)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:306)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:307)
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:293)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:270)
at org.postgresql.jdbc.PgStatement.executeQuery(PgStatement.java:224)
at my.SaveRepostedToFile.main(SaveRepostedToFile.java:10)

有什么办法可以避免OOM?

4

0 回答 0