This week's book giveaway is in the Cloud forum.
We're giving away four copies of The Business Blockchain and have William Mougayar on-line!
See this thread for details.
Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception with straightforward JDBC getConnection error to Oracle

 
Tom Griffith
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. If you have a minute, this is driving me over the edge. I've used ojdbc14.jar in the past and never really had any issues. However, I am getting strange errors today with just some very basic code for testing and I have tried ojdbc14.jar, ojdbc5.jar, ojdbc6.jar


pretty standard jdbc connection...

Class.forName("oracle.jdbc.driver.OracleDriver").newinstance;

Connection conn=DriveManaer.getConnection("jdbcracle:thin:@server.here.com:1521:TSTSID","username"."password");

........................

using ojdbc14.jar, I get NullPointerException at the conn line

using ojdbc5.jar or ojdbc6.jar, I get ArrayIndexoutOfBoundsException -1 at the conn line

----------------------------------------------------------------------

I have entered the IP instead of server.here.com and get the same results as above...

Connection conn=DriveManaer.getConnection("jdbcracle:thin:@IP.IP.IP.IP:1521:TSTSID","username"."password");

I have pinged server.here.com and IP and it sends back a response

---------------------------------------------------------------------------


I am also able to connect to a legacy SQL Server database on a different server using the same exact code except with the jtds driver...so I don't think it's a local issue...

Connection conn=DriverManager.getConnection("jdbc.jtds.sqlserver://IP.IP.IP.IP:1433/LMDB;TDS=8.0":username":"password")


----------------------------------------------------------------------------


does anybody see what could be wrong? thank you so much for your time.

 
K. Tsang
Bartender
Posts: 3583
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given you are using SID to connect to Oracle, the JDBC url looks alright.

What java version are you using?
Java 1.4 = ojdbc14.jar
Java 5 = ojdbc5.jar
Java 6 = ojdbc6.jar
Java 7 = ojdbc6.jar or another jar

Is the program doing other things other than connecting? Because the Class.forName and DriverManager.getConnection do not throw ArrayIndexOutBoundsException all of a sudden.

Noticed your Class.forName() is a bit off.

 
Dave Tolls
Ranch Hand
Posts: 2091
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom Griffith wrote:using ojdbc14.jar, I get NullPointerException at the conn line

using ojdbc5.jar or ojdbc6.jar, I get ArrayIndexoutOfBoundsException -1 at the conn line


Have you go the full stack traces for those exceptions?

That Class.forName is not required anymore.
Hasn't been for quite some time.

As K. Tsang points out, make sure you have the right driver for your Java version.
 
Tom Griffith
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much for replying and for your help.

I'm not exactly sure what jvm lotus notes 8.5.3 is running (I know 8.5.3 is running jvm6) so I tried both ojdbc5 and ojdbc6. Give the same error.

The code is doing virtually nothing else (except some object declarations). I've eliminated everything else to try to get to the source of this issue. It's a local Lotus notes agent and I have the connection in it's own try block where the OutOfBoundsexception is caught...


I also fixed the class.forName, same errors...



Class.forName("oracle.jdbc.OracleDriver").newinstance;

try {

Connection conn=DriveManager.getConnection("jdbcracle:thin:@server.here.com:1521:TSTSID","username"."password");

} catch (SQLException se) {

System.out.println("SQL Exception - " + se.toString());

} catch (Exception e) {

''THIS PRINTS OUT Of BOUNDS EXCEPTION -1
System.out.println("e.toString());

} finally {

conn.close();

}

This is driving me crazy.

now it gets weirder. I just tried something, if I put something bogus in for the URL, like

Connection conn=DriveManager.getConnection("jdbcracle:thin:@WACKY.com:1521:TSTSID","username"."password");

the error is then "The network Adapter could not establish the connection"...

but putting the real URL back, it's back to the java.lang.ArrayIndexOutOfBoundsException: Array index out of range -1


 
Tom Griffith
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave, here is a full stack trace...I can't make anything out of it except something with authentication, but it seems to be with te driver and not on the server...

DEFAULT EXCEPTION - java.lang.ArrayIndexOutOfBoundsException: Array index out of range: -1
at oracle.jdbc.driver.T4CTTIoauthenticate.setSessionFields(T4CTTIoauthenticate.java:948)
at oracle.jdbc.driver.T4CTTIoauthenticate.<init>(T4CTTIoauthenticate.java:225)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:351)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:531)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:221)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:503)
at java.sql.DriverManager.getConnection(DriverManager.java:322)
at java.sql.DriverManager.getConnection(DriverManager.java:358)
at JavaAgent.NotesMain(JavaAgent.java:58)
at lotus.domino.AgentBase.runNotes(Unknown Source)
at lotus.domino.NotesThread.run(Unknown Source)
 
K. Tsang
Bartender
Posts: 3583
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try running the program outside Lotus Notes.

For JDBC4 the Class.forName() is not needed. JDBC3 still need. For backward compatibility, having it doesn't hurt.
 
Tom Griffith
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was just thinking about it,, I didn't download ojdbc5 and ojdbc6 from Oracle because I couldn't find them I downloaded them from www.java2s.com. Could they be screwed up versions, maybe? I still cant find where to download tem direct from Oracle...

But then again, the code with ojdbc14.jar (which I've used for years) is throwing practically the same exception with the full stack trace, just from a different method...it has this at the top

at oracle.gss.util.NLSLocale.getNLSLanguage(NLSLocale.java.675)...then the rest of the trace is viertually the same across all ojdbc14, ojdbc5, ojdbc6

I've been googling on the T4CTTloadAuthenticate.SetSessionFields and see people with apparently the same issue but no solutions yet. Ugh. But the first line of the trace using ojdbc14 seems to indicate a Locale language issue, whatever that is.
 
Dave Tolls
Ranch Hand
Posts: 2091
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html
You can get the drivers from there.
What version of Oracle are you on?
 
Tom Griffith
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave, thank you. yeah, like earlier, I go to the Oracle site and when I follow the link to ojdbc5.jar or ojdbc6.jar, they take me to some other "overview" page, I can't seem to locate the specific jars for download...

I have to find out what version of Oracle form the admins. I'm starting to think it's not the drivers though since ojdbc14.jar which I've used for years threw the same thing. I have to set up the jdk on the lotus notes pc to run standalone outside of lotus notes, but ultimately, this has to run in lotus notes.
 
Tom Griffith
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. I think I found something. I ran it standalone Java as you suggested K. Tsang and it connected. I remembered something about Lotus Notes and external jars and moved the ojdbc5.jar file to Lotus\Notes\jvm\lib\ext directory and it seems to work ok now now. I have ojdbc5.jar as part of the "project" in the agent so apparently external jars have to go to Lotus\Notes\jvm\lib\ext as well. There must be a way to not have to do that since they have the option to add to the agent "project" but at least this vague error has 86'd itself (for now, hopefully forever, but I haven't even started the SQL).

Thank you again for reading about this hurdle, guys.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic