Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: [JDBC] StoredProcedure cursor returned is not TYPE_SCROLL_INSENSITIVE

Re: [JDBC] StoredProcedure cursor returned is not TYPE_SCROLL_INSENSITIVE

From: Joe Weinstein <joeNOSPAM_at_bea.com>
Date: Fri, 17 Feb 2006 16:05:37 -0800
Message-ID: <43F664D1.5040303@bea.com>

hikemike_at_gmail.com wrote:

> I have seen the problem reported in various news groups going back to
> 1999 (Deja.News). Does anyone know if it's been fixed yet. There
> appears to be no solution on the web.
>
> I call a simple stored procedure from a java program and use the
> following line:
>
> protected static final String GET_ACCOUNTS_PROC = "{call
> ACCOUNT.GET_ACCOUNTS_PROC_ALL(?,?)}";
>
> cs = connection.prepareCall(GET_ACCOUNTS_PROC,
> ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
>
> cs.execute();
> rset = (ResultSet) cs.getObject(2);
> rset.first();
>
> throws a SQL Exception:
>
> Invalid operation for forward only resultset : first
>
> Ridiculous that I can't do this. Someone please tell me I'm wrong.
>
> oracle 9 driver: ojdbc14.jar --> jdbc:oracle:thin driver

Well, in your case, the call to first() is identical semantically to if you simply called next(), so maybe you can just do that.

   If the driver wanted to be clever and friendly, it maybe could make it's scrollable-resultset methods do what you want in the rare cases when they can, such as if you were on the second-to-last row, last() would be the same as next(), or if you were at the 7th row and called absolute(8) it would mean the same as next() etc.

   That would just be too tricky for not much real user benefit, so I wouldn't hold up too many hopes for it. Just stick to the simple JDBC 1.0 methods that will completely process the result set type you asked for:

cs.execute();
rset = (ResultSet) cs.getObject(2);
if (rset.next()) ... // do what you want with the first row

Note that your original code depends on the result set not being empty...

You can't go wrong with the standard:
cs.execute();
rset = (ResultSet) cs.getObject(2);
while(rset.next())
{

     do whatever. You can track whether this is the first row if that's important }
rset.close();

HTH,
Joe Weinstein at BEA Systems Received on Fri Feb 17 2006 - 18:05:37 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US