Hi,
I posted this topic under the Oracle 9i section before but got no reply.
Basically I have the following code trying to connect to my Oracle Database but it does not appear to be working:
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 = "jdbcracle:thin" +dbhost+":1521:" +dbsid;
//String url = "jdbcdbc:"+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: jdbcracle:thinlaptop117:1521:tiger
Setting PrintWriter:
DriverManager.getConnection("jdbcracle:thinlaptop117: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_charset12.zip
Can anyone please point out what is going wrong and what I need to do to fix this.
Thanks,
Tom
I posted this topic under the Oracle 9i section before but got no reply.
Basically I have the following code trying to connect to my Oracle Database but it does not appear to be working:
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 = "jdbcracle:thin" +dbhost+":1521:" +dbsid;
//String url = "jdbcdbc:"+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: jdbcracle:thinlaptop117:1521:tiger
Setting PrintWriter:
DriverManager.getConnection("jdbcracle:thinlaptop117: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_charset12.zip
Can anyone please point out what is going wrong and what I need to do to fix this.
Thanks,
Tom