File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC 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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "scrollable result set, but still an error" Watch "scrollable result set, but still an error" New topic
Author

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 = SNTS_CConnection.open();
objStmt = (OracleCallableStatement)objConn.prepareCall("{? = call
SCHEMA.TABLE.SPROC (?,?)}",
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
objStmt.registerOutParameter(1, oracle.jdbc.driver.OracleTypes.CURSOR);
objStmt.setString(2, strSomething);
objStmt.setString(3, strSomethingElse);
objStmt.execute();
rs = (ResultSet)objStmt.getObject(1);
rs.next(); //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:
"oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
java.sql.SQLException
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,
bryan


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

Joined: Oct 11, 2000
Posts: 1121

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:
http://technet.oracle.com
http://asktom.oracle.com
http://metalink.oracle.com
Have you checked the Oracle documentation? It may verify that "ref cursors"s cannot be scrollable.
Oracle documentation available from:
http://tahiti.oracle.com
Hope this helps.
Good Luck,
Avi.
bryan nelson
Ranch Hand

Joined: Jun 16, 2003
Posts: 95
Hello again,
Upon further review of the Orcale 8.1.6.0.0 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 8.1.6.0.0 (or the latest 8.1.7.1) 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!
bryan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: scrollable result set, but still an error
 
Similar Threads
best way to return connection back to the connection pool
java.lang.ClassCastException when invoking jdbc stored procedure call
ClassCastException :SerialConnection
SCROLLABLE RESULTSET PROBLEM
ResultSet is not scrollable problem - WAS 3.5 (Very Urgent please)