JDBC connection pukes (please advise)
Hello everyone,
I'm new to programming java, but have done developement in C/perl. I'm trying to access this Oracle8i db on the network. The DB is on Irix 6.1 and i'm running win2K, the tnsnames.ora is already set and the db is refered to as mmx. We are runningoracle 8.1.6 on it. I went to Oracle's website and selected to download some appropriate JDBC drivers they had the following choices:
Oracle 8 JDBC OCI and JDBC Thin Drivers
Download the drivers NT
Version 8.0.5.2 JDBC(Thin and OCI)for NT
Version 8.0.4.0.6for NT 4.0
Oracle JDBC Drivers
Download the drivers NT
Oracle8i 8.1.7 JDBC Driversfor use with JDK 1.2.xfor NT
Oracle8i 8.1.7 JDBC Driversfor use with JDK 1.1.xfor NT
Oracle 8i (8.1.5) JDBC Driversfor use with JDK 1.1.xfor NT
Oracle 8i (8.1.5) JDBC Driversfor use with JDK 1.0.2for NT
So they dont have drivers for 8.1.6? which is lame. Anyways i proceeded to download:
Oracle8i 8.1.7 JDBC Drivers for use with JDK 1.2.x for NT
I'm runningjdk1.2.2 I'm also using TextPad as my editor (it has tools for compiling and running java applications, very cool) Ok so heres the problem, i have a very simple program to try connecting to the DB, It compiles just fine but during run time i get the following errors. I have included the new classes12.zip in my classpath and all. But not really sure what going on. here's my code followed by the errors. Any advice would be greatly appreciated.
CODE
import java.net.URL;
import java.sql.*;
import java.math.*;
class jdbc_connect{
publicstaticvoid main(String argv[]){
if (argv.length == 0){
System.err.println("Usage:");
System.err.println("");
System.err.println("java jdbc_connect URL");
}
try{
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
String url ="jdbc:oracle:thin:@mmx2";
String url2 ="mmx2";
String user, pwd;
if (argv.length > 1){
user = argv[1];
}else{
user ="saeedf";
}
if (argv.length > 2){
pwd = argv[2];
}else{
pwd ="saeedf01";
}
Connection con = DriverManager.getConnection(url, user, pwd);
con.close();
System.out.println("Connection Successful.");
}
catch (Exception e){
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
ERRORS when executed
Usage:
java jdbc_connect URL
null
java.lang.NullPointerException
at oracle.jdbc.ttc7.TTCOutBuffer.add(TTCOutBuffer.java:129)
at oracle.jdbc.ttc7.TTIMsg.marshalUB1(TTIMsg.java:372)
at oracle.jdbc.ttc7.TTIpro.marshal(TTIpro.java:234)
at oracle.jdbc.ttc7.TTIpro.<init>(TTIpro.java:96)
at oracle.jdbc.ttc7.TTC7Protocol.connect(TTC7Protocol.java:1028)
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:186)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:127)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
va:170)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:148)
at java.sql.DriverManager.getConnection(DriverManager.java:457)
at java.sql.DriverManager.getConnection(DriverManager.java:137)
at jdbc_connect.main(jdbc_connect.java:35)
Press any key tocontinue . . .
I'm not sure whats going on with DriverManager. Before it wasnt able to load the right drivers. That error went away after i changes my classpath, and now this. very lost. Here are my environment variables too:
CLASSPATH=%JAVA_HOME%\jre\lib\rt.jar;.;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\jre\lib\ext;C:\Oracle\Ora81\orb\classes\yoj.jar;C:\Oracle\Ora81\orb\classes\share.zip;C:\jarfiles\classes102.zip;C:\jarfiles\classes111.zip.;C:\jdk1.2.2\lib\classes.zip;C:\jdk1.2.2\bin;C:\jarfiles\classes12.zip
JAVA_HOME=c:\jdk1.2.2
PATH=.;%JAVA_HOME%\bin;C:\Oracle\Ora81\bin;"C:\Program Files\Oracle\jre\1.1.7\bin";C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;c:\dell;"C:\Program Files\Dell\Resolution Assistant\Common\bin";%SystemRoot%\system32\nls\English;"C:\Program Files\Common Files\MDL Shared\ISIS";C:\Oracle\Ora81\orb\bin;C:\jdk1.2.2\bin;C:\windows;C:\windows\command;C:\jdk1.2.2\bin
Please some Java guru advise me on what to do. As these errors are not making much sense. Do i have my URL wrong? or is the DriverManager having trouble registering the driver?

