Обсуждение: OutOfMemoryError

Поиск
Список
Период
Сортировка

OutOfMemoryError

От
rstepha1@nycap.rr.com
Дата:
I am having a problem with performing large selects and getting a
java.lang.OutOfMemoryError.

Database: 8.0.1 JVM: 1.5 Driver: 8.0-311 JDBC 3

Using a simple select: SELECT col1, col2 FROM schm.tab1 WHERE col2
BETWEEN 30000 AND 31000

It seems that the ResultSet is containing the entire selected set of
data and not using a cursor within the database engine.  I have tried
setting the resultSetType and resultSetConcurrency to TYPE_FORWARD_ONLY
and CONCUR_READ_ONLY respectively to hopefully force the cursor
management to be server oriented, without success.

It is possible to work around by increasing the heap size or lowering
the selection criteria, but ...

How do you get the driver to not retrieve all of the data into the
ResultSet?  Is there a setting either within the JDBC driver, or at the
database that would determine caching X number of rows returned at a time?

Richard

Re: OutOfMemoryError

От
Kris Jurka
Дата:

On Mon, 29 Aug 2005 rstepha1@nycap.rr.com wrote:

> I am having a problem with performing large selects and getting a
> java.lang.OutOfMemoryError.
>
> How do you get the driver to not retrieve all of the data into the
> ResultSet?  Is there a setting either within the JDBC driver, or at the
> database that would determine caching X number of rows returned at a time?
>

http://jdbc.postgresql.org/documentation/80/query.html#query-with-cursor

Kris Jurka

Re: OutOfMemoryError

От
Marc Herbert
Дата:
rstepha1@nycap.rr.com writes:

> It seems that the ResultSet is containing the entire selected set of
> data and not using a cursor within the database engine.  I have tried
> setting the resultSetType and resultSetConcurrency to TYPE_FORWARD_ONLY
> and CONCUR_READ_ONLY respectively to hopefully force the cursor
> management to be server oriented, without success.
>
> It is possible to work around by increasing the heap size or lowering
> the selection criteria, but ...
>
> How do you get the driver to not retrieve all of the data into the
> ResultSet?  Is there a setting either within the JDBC driver, or at the
> database that would determine caching X number of rows returned at a time?

Try this:

   myStatement.setFetchSize(43);

Warning: according to the JDBC spec, it's just a "hint", the driver
may still do what it thinks is good.