?
Solved

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

Posted on 2003-03-02
16
Medium Priority
?
375 Views
Last Modified: 2011-09-20
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.
0
Comment
Question by:kaustubhpatil
  • 4
  • 3
  • 2
  • +5
15 Comments
 

Expert Comment

by:ampathak
ID: 8055342
Can you give the select statement here, so that the things will get more clearer
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 8055407
As you said, 7th parameter is LONG, so, you should use proper get method to extract that, probably this will work:-


rsDocs.getBigDecimal(7)
0
 
LVL 92

Expert Comment

by:objects
ID: 8055425
does your rs actually have 9 columns?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 4

Expert Comment

by:boxy73
ID: 8055646
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).

0
 

Author Comment

by:kaustubhpatil
ID: 8055662
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().
!!!!
0
 
LVL 92

Accepted Solution

by:
objects earned 200 total points
ID: 8055724
try using getObject()
0
 

Author Comment

by:kaustubhpatil
ID: 8055781
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....
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 8055814
Can you post the code which you are using to execute the stored procedure?
0
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 200 total points
ID: 8087629
Its always better to use the names of the table-attributes in getString () or getLong (). For example, if the name of that long attribute (column-name) in your table is "LongAttribute" and let's say that you have a string attribute "StringAttribute", then simply write:


long longValue ;
String str ;

while ( resultset.next () )
{
  str = resultset.getString ( "StringAttribute" ) ;
  longValue = resultset.getLong ( "LongAttribute" ) ;
  ....
  ....

} // end while


getString (), getLong (), getInt (), getDate (), etc are all overloaded.

Mayank.
0
 

Expert Comment

by:CleanupPing
ID: 9058970
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.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 9058995
Recommendation: Accept mayankeagle's comment as answer :-)
0
 
LVL 92

Expert Comment

by:objects
ID: 9062985
I doubt your answer will fix it.
More likely kaustubhpatil does not have enough placeholders included in his sql string.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 9063001
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.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 9721237
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
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 9721770
Please go ahead.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question