Link to home
Start Free TrialLog in
Avatar of kaustubhpatil
kaustubhpatil

asked on

Oracle JDBC driver givin problems when reading a LONG from the oracle database !!!

Hi,

I am reading a resultset in a usual manner by doing the while(resultset.next()) method.

I get an "ArrayIndexOutOfBoundsException" when the driver is reading the "LONG" type of value returned by the PLSQL procedure.

Again the problem is that when I am returning the LONG column as the first in the select there is no error, but when I change the position of the LONG column in the select the exception starts occuring from that line. And again its ArrayOutOfBoundsException.

I hv pasted the code below..
------------
while(rsDocs.next()){
dID = rsDocs.getString(1);
stat = rsDocs.getString(2);
dTypeCode = rsDocs.getString(3);
suppD = rsDocs.getString(4);
pNum = rsDocs.getString(5);
rDate = rsDocs.getString(6);
sNote = rsDocs.getString(7);
cNum = rsDocs.getString(8);
strSer = rsDocs.getString(9);
}
--------------
Here I am reading the LONG as the 7th column (sNote). It throws the exception.
Even if I comment that line
----------------
//sNote = rsDocs.getString(7);
----------------
I start to get the exception on the next statement.

So I have guessed that the problem is when the driver reads the LONG value from the DB and not when it is read from the resultset.

But the question remains, What/Why the problem ??
And on top of it, why not when the column is the 1st column selected !!!

Any explanations ???

Thanks,
Kaustubh.
Avatar of ampathak
ampathak

Can you give the select statement here, so that the things will get more clearer
As you said, 7th parameter is LONG, so, you should use proper get method to extract that, probably this will work:-


rsDocs.getBigDecimal(7)
Avatar of Mick Barry
does your rs actually have 9 columns?
Perhaps you don't have 9 columns, or your SQL statement is not properly formed for this second try.

Anyway, when working, I suggest you should use rsDocs.getLong(7) to retrieve a Long value (never getString).

Avatar of kaustubhpatil

ASKER

OK,
I will clarify all your doubts.
Yes, my resultset actually has 9 coulumns. I have checked it using the ResultSetMetadata.
I cannot get the value using the getBigDecimal() or anything because a "LONG" value in the PLSQL actually is a alphanumeric and not numeric. So it has to be reterived using getString().
!!!!
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Using getObject doesn't help.
As I said in my first post evenif I coomment out the column that is giving problem the exception is thrown from the next statement.
So whatever is used to read from the resultSet, or even if the value from the resultset is never used the program still gives exception on the next line....
Can you post the code which you are using to execute the stored procedure?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
kaustubhpatil:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
Recommendation: Accept mayankeagle's comment as answer :-)
I doubt your answer will fix it.
More likely kaustubhpatil does not have enough placeholders included in his sql string.
Hi objects.... its been a long while! Well, I know that my solution might or might not help.... that's why I left the smiley after it :-) anyway, by now he must've fixed it!

Cheers,
Mayank.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Split between objects and mayankeagle.

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TimYates
EE Cleanup Volunteer
Please go ahead.