Home » Developer & Programmer » JDeveloper, Java & XML » Thin Driver and ArrayIndexOutOfBounds exception
Thin Driver and ArrayIndexOutOfBounds exception [message #153603] Tue, 03 January 2006 05:24 Go to next message
tlohan
Messages: 1
Registered: January 2006
Junior Member
Hi,

On my Windows XP system I have Oracle 9.2.0.5.0 and JDK 1.4.2_10 installed.

I have a ZeroG InstallAnywhere piece of software which prompts for DB username, password, SID and server and users this info to do a JDBC thin connection to the database to ensure it exists. This does not appear to be working for me on my localmachine, however, if I try to connect to a DB on another server it works fine. The DB on the other server is also at 9.2.0.5.0

The core of the code trying to connect to my Oracle Database is:

private boolean getDatabaseConnection(String dbhost, String dbsid, String dbusername, String dbpassword) {
FileOutputStream out; // declare a file output object
PrintStream p; // declare a print stream object

try {
out = new FileOutputStream("C:\\Installs\\nCharge\\tom.txt");
p = new PrintStream( out );
p.println("Params: "+ dbhost + "," + dbsid + "," + dbusername + "," + dbpassword);

String url = "jdbc:oracle:thin:@" +dbhost+":1521:" +dbsid;
//String url = "jdbc:odbc:"+dbsid;
// Load the Oracle JDBC Driver and register it.
//System.out.println("DB URL: "+url);
p.println("DB URL: "+url);

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
p.println("Setting PrintWriter:");
DriverManager.setLogWriter(new PrintWriter((p)));
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
myCon = DriverManager.getConnection(url, dbusername, dbpassword);
return true;
} catch(SQLException ex) {
try {
//System.out.println("SQL Exception: " + ex.getMessage());
out = new FileOutputStream("C:\\Installs\\nCharge\\tom1.txt");
p = new PrintStream( out );
p.println("SQL Exception: " + ex.getMessage());
} catch (FileNotFoundException ey) {

}
return false;
}catch(Exception e) {
try {
//System.out.println("Exception: " + e.getMessage());
out = new FileOutputStream("C:\\Installs\\nCharge\\tom2.txt");
p = new PrintStream( out );
p.println("Exception: " + e);
p.println("Exception: " + e.getMessage());
e.printStackTrace(p);
} catch (FileNotFoundException ez) {

}
return false;
}
}

The debug from the DriverManager section results in this output:

Params: laptop117,tiger,tom,tom
DB URL: jdbc:oracle:thin:@laptop117:1521:tiger
Setting PrintWriter:
DriverManager.getConnection("jdbc:oracle:thin:@laptop117:1521:tiger")
trying driver[className=oracle.jdbc.driver.OracleDriver,oracle.jdbc.driver.OracleDriver@1bc1806]

An exception is raised and the output of this is:

Exception: java.lang.ArrayIndexOutOfBoundsException: 7
Exception: 7
java.lang.ArrayIndexOutOfBoundsException: 7
at oracle.security.o3logon.C1.r(C1)
at oracle.security.o3logon.C1.l(C1)
at oracle.security.o3logon.C0.c(C0)
at oracle.security.o3logon.O3LoginClientHelper.getEPasswd(O3LoginClientHelper)
at oracle.jdbc.ttc7.O3log.<init>(O3log.java)
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at CheckDB.getDatabaseConnection(CheckDB.java:49)
at CheckDB.install(CheckDB.java:21)
at com.zerog.ia.installer.actions.CustomAction.installSelf(Unknown Source)
at ZeroGtz.run(Unknown Source)

Under Start --> My Computer (Right Click on it) --> Properties --> Advanced Tab --> Environment Variables I have an entry for CLASSPATH of:

.;C:\oracle\ora92\jdbc\lib;C:\oracle\ora92\jdbc\lib\ojdbc14.zip;C:\oracle\ora92\jdbc\lib\classes12.zip;C:\oracle\ora92\jdbc\lib\nls_c harset12.zip


Creating a local script of:


import java.sql.*;

public class TestConnection {
public static void main(String args[]) throws Exception {
String server = "laptop117";
String sid = "tiger";
String user = "tom";
String password = "tom";

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection c = DriverManager.getConnection("jdbc:oracle:thin:@" +server +":1521:" +sid, user, password);
System.out.println("got connection : " +c);
}
}

I am able to connect to the DB without any issue.

What is going wrong and how can I correct this?

Thanks,

Tom
Re: Thin Driver and ArrayIndexOutOfBounds exception [message #156096 is a reply to message #153603] Fri, 20 January 2006 13:02 Go to previous message
ienabler
Messages: 2
Registered: January 2006
Location: GA
Junior Member

Tell me about Thin Driver> in java/oracle
Previous Topic: Reading a Oracle Source Code (FMB) using JDAPI
Next Topic: Difficulties of build a web-based application on Oracle XML DB
Goto Forum:
  


Current Time: Fri Apr 26 00:29:29 CDT 2024