Re: JDBC stored procs doc patch

From: Fernando Nasser <fnasser(at)redhat(dot)com>
To: Nic <nferrier(at)tapsellferrier(dot)co(dot)uk>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: JDBC stored procs doc patch
Date: 2003-07-30 15:24:40
Message-ID: 3F27E338.5090008@redhat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc pgsql-patches

Hi Nic,

It is great to see someone trying to improve the documentation.

I have a few questions about the first part (about fetch size):

> +
> + <para>Changing code to cursor mode is as simple as setting the
> + fetch size of the <classname>Statement</classname> to the
> + appropriate size. Setting the fecth size back to 0 will cause
> + all rows to be cached (the default behaviour).
> +

Perhaps you should mention the retrieval all rows must happen inside a
transaction. The cursor that is created is not HOLD or anything.

> +<programlisting>
> +Statement st = db.createStatement();
> +// Turn use of the cursor on.
> +st.setFetchSize(50);
> +ResultSet rs = st.executeQuery("SELECT * FROM mytable");
> +while (rs.next()) {
> + System.out.print("a row was returned.");
> +}
> +rs.close();
> +// Turn the cursor off.
> +st.setFetchSize(0);
> +ResultSet rs = st.executeQuery("SELECT * FROM mytable");
> +while (rs.next()) {
> + System.out.print("many rows were returned.");
> +}
> +rs.close();
> +// Close the statement.
> +st.close();
> +</programlisting>
> + </para>
> +
> +

I do not understand what the example is supposed to show. The fetch
size is transparent to the user (it is just a hint to the driver about
what should be the best strategy) so you should be able to get all the
rows, and the same number of them, as you go doing rs.next().

Regards,
Fernando

--
Fernando Nasser
Red Hat Canada Ltd. E-Mail: fnasser(at)redhat(dot)com
2323 Yonge Street, Suite #300
Toronto, Ontario M4P 2C9

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Nic 2003-07-30 15:40:55 Re: JDBC stored procs doc patch
Previous Message Kim Ho 2003-07-30 14:32:50 SetFetchSize and SetFetchDirection

Browse pgsql-patches by date

  From Date Subject
Next Message Josh Berkus 2003-07-30 15:27:47 Re: [PATCH] Re: [pgsql-advocacy] Why READ ONLY transactions?
Previous Message Sean Chittenden 2003-07-30 05:05:34 [PATCH] Re: Why READ ONLY transactions?