Re: OutOfMemory - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: OutOfMemory
Date
Msg-id 406BC172.20707@opencloud.com
Whole thread Raw
In response to Re: OutOfMemory  (Guido Fiala <guido.fiala@dka-gmbh.de>)
Responses Re: OutOfMemory
List pgsql-jdbc
Guido Fiala wrote:
> Oliver Jowett wrote:
>
>>(... later ...) Hold on -- doesn't last() require a scrollable
>>resultset, which means you're not using a cursor behind the scenes? I
>>think the driver does not throw an exception if you try to use
>>last()/absolute()/etc with FETCH_FORWARD_ONLY (it should!) but instead
>>just gives you the wrong results.. not great, but this is not only the
>>fault of the driver :)

[...]

> So i walked through the source tree and saw that it only would use the
> fetchsize by using "FETCH FORWARD ..." if the ResultSetType is set to
> FETCH_FORWARD_ONLY.
> This does indeed fetch only fetchsize rows but then i was stuck... so here
> is my TextCase:

[...]

>             //test forward-only
>             System.out.println("test: TYPE_FORWARD_ONLY");
>             conn.setAutoCommit(false);//to allow cursors below
>             Statement
> st=conn.createStatement(ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY);
>             st.setFetchSize(1);
>             ResultSet rs=st.executeQuery("Select * from tst_fetchsize");
>             rs.last();//now we should be at "count"

Indeed, here's your problem -- you're not allowed to call last() on a
TYPE_FORWARD_ONLY resultset. The driver should throw an exception at
this point (but currently doesn't). See the ResultSet.last() javadoc for
details.

-O

pgsql-jdbc by date:

Previous
From: Oliver Jowett
Date:
Subject: Re: very interesting JDBC problem ...
Next
From: Guido Fiala
Date:
Subject: Re: OutOfMemory