Home > Archive > PostgreSQL JDBC > September 2005 > Result Set FORWARD_ONLY









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Result Set FORWARD_ONLY
Jeffrey Melloy

2005-09-23, 3:23 am

I'm having trouble setting the result set to anything but FORWARD_ONLY.

If I do this:

pstmt = conn.prepareStatement("select name, name from
amz. product_detail_items
order by name");
rs = pstmt.executeQuery();
rs. setFetchDirection(Re
sultSet. TYPE_SCROLL_INSENSIT
IVE);

I get:

org.postgresql.util.PSQLException: Invalid fetch direction constant:
1,004.

I get the same error if I set it on the pstmt object before executing
the query.

Using version 311 of the JDBC driver and 8.0.2.

Thanks,
Jeff
Oliver Jowett

2005-09-23, 3:23 am

Jeffrey Melloy wrote:

> pstmt = conn.prepareStatement("select name, name from
> amz. product_detail_items
order by name");
> rs = pstmt.executeQuery();
> rs. setFetchDirection(Re
sultSet. TYPE_SCROLL_INSENSIT
IVE);
>
> I get:
>
> org.postgresql.util.PSQLException: Invalid fetch direction constant: 1,004.


The driver is working correctly here.

You can only set the resultset type when creating the statement, like so:

> pstmt = conn.prepareStatement("select name, name from amz. product_detail_items
order by name", ResultSet. TYPE_SCROLL_INSENSIT
IVE, ResultSet.CONCUR_READ_ONLY);


ResultSet.setFetchDirection() is used to hint to the driver about the
expected order of resultset use, not to set the resultset type. It
expects one of ResultSet.FETCH_FORWARD, ResultSet.FETCH_REVERSE, or
ResultSet.FETCH_UNKNOWN. The driver is (correctly) complaining that
you're giving it some other value.

The java.sql javadoc covers all this.

-O

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com