wood burning stoves 2.0*
The moose likes JDBC and the fly likes On connection: Array Index Out Of Bounds Exception: 4 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "On connection: Array Index Out Of Bounds Exception: 4" Watch "On connection: Array Index Out Of Bounds Exception: 4" New topic
Author

On connection: Array Index Out Of Bounds Exception: 4

deb platt
Ranch Hand

Joined: Jan 23, 2008
Posts: 44
When I try to connect to our Oracle Database, I am getting this exception:


Below is my code:


open is called by this code:

Where myhost, mydomain, and myport are something reasonable.

Any suggestions as to how I might go about debugging this problem? I saw the exact same problem described at an Oracle forum, but no one replied to the post.

Deb
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38472
    
  23
At least somebody will reply here.

I can't see anything which is likely to throw an out of bounds exception here.
Are you passing any arrays to anything which might pass them to T4C8 etc?
Are you passing any multiple parameters (look for an ellipsis ... in the last parameter of any methods you are calling)? It

Put your entire code onto an IDE like Eclipse. Run it until you get the same exception. When you get the stack trace, it has the lines underlined; they are rather like hyperlinks. If you click one of the hyperlinks in your stack trace, you might get sight of the original code.

Sorry I can't help any more. Try those things, and when they don't work, maybe somebody else will know what to do.
deb platt
Ranch Hand

Joined: Jan 23, 2008
Posts: 44
It appears that the problem was due to using the wrong release of Oracle's JDBC thin drivers. I am trying to connect to an Oracle8 RDMS. If I compile the above code with java1.5, I thought I should use Oracle's ojdbc5.jar for the drivers, as Oracle says these are the drivers corresponding to java1.5. So that's what I did.

I returned to the Readme.txt that was included in my download for ojdbc5.jar. It said that the package oracle.jdbc.driver has been removed in JDBC 11R1 (which is ojdbc5.jar). If you note above, I was using this package in the statement which loaded the driver:

According to Readme.txt, I should be able to fix the problem by replacing oracle.jdbc.driver with oracle.jdbc. I tried the following code:

However I still got ArrayIndexOutOfBoundsException: 4. I then tried using the DataSource method for opening a connection:

However, this threw an ORA-12514 exception saying that the listener didn't know the requested service. In the event that I was doing something syntactically wrong, I tried using ods.setServerName, ods.setPortNumber, and ods.setDatabaseName, but this time I got an exception saying that Oracle didn't know how to make the URL.

I am not sure if it is even possible to use ojdbc5.jar with oracle8, or whether I am making some error in my code. However if I use the originally posted code and instead use classes12.zip or classes111.zip, everything works fine. So for the time being I am going back to these earlier releases of Oracle's JDBC drivers.
[ March 05, 2008: Message edited by: deb platt ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: On connection: Array Index Out Of Bounds Exception: 4