File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes scrollable result set, but still an error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "scrollable result set, but still an error" Watch "scrollable result set, but still an error" New topic

scrollable result set, but still an error

bryan nelson
Ranch Hand

Joined: Jun 16, 2003
Posts: 95
Hello all,
*I know this may look like a repeat post at first glance, but I assure you it is not. I've read all the posts in this forum already.*
Okay, the end goal here is to use the .last() method of the java.sql.ResultSet(). I realize that in order to use this you must have a scrollable resultset, which I have already specified as you can see in the code below. A few items of interest: We're using
JDK 1.2.2 (don't ask why)
Oracle 8i
Here's the code:
Connection objConn = null;
OracleCallableStatement objStmt = null;
objConn =;
objStmt = (OracleCallableStatement)objConn.prepareCall("{? = call
objStmt.registerOutParameter(1, oracle.jdbc.driver.OracleTypes.CURSOR);
objStmt.setString(2, strSomething);
objStmt.setString(3, strSomethingElse);
rs = (ResultSet)objStmt.getObject(1);; //having or not having this line makes no difference
if (m_rsResults.last()) //BREAKS HERE
//nice code
Now, on the line that is commented as breaking above i receive this error at runtime:
Invalid operation for forward only resultset : last "
It should also be noted that the SQL code in the sproc works fine if embedded directly into the java.
As you can see, I've used the TYPE_SCROLL_INSENSITIVE (and the CONCUR_READ_ONLY for that matter) and I'm still receiving the error. Any help would be greatly appreciated!!
Thanks in advance,

"...and the Truth will set you free."
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1141

Hi Bryan,
I'm only guessing, but it appears that a "ref cursor" returned from an Oracle stored procedure cannot be scrollable.
Have you tried searching the following Web sites:
Have you checked the Oracle documentation? It may verify that "ref cursors"s cannot be scrollable.
Oracle documentation available from:
Hope this helps.
Good Luck,
bryan nelson
Ranch Hand

Joined: Jun 16, 2003
Posts: 95
Hello again,
Upon further review of the Orcale documentation, it is very clear that scrollable resultsets can indeed be used in this version. In fact, I have gotten them to work quite nicely...however, the problem here is that I'm using a stored procedure as well (see code above).
So the ultimate question here is:
Using JDBC 2.0, and the Oracle (or the latest drivers, and jdk 1.2.2: Can a scrollable resultset (ref cursor) be returned from an Oracle stored procedure?
I have scanned all of the documentation listed above...thanks for the resources...but have come up dry. Surely someone must know this answer?Many thanks to all who try!
I agree. Here's the link:
subject: scrollable result set, but still an error
It's not a secret anymore!