DriverManager.getConnection NullPointerException [message #92639] |
Tue, 02 November 2004 11:18 |
Bobman
Messages: 2 Registered: November 2004
|
Junior Member |
|
|
I am writing an applet that inserts data to an oracle database. it works fine on the oracle server, by running main() or using applet viewer. However, when I run remotely, I get a NullPointerException when I try to get a connection.
Here is my code:
/////////////////////////////////////////////////////////
.......
System.out.print("Registering driver...rn");
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
}
catch(java.sql.SQLException e)
{
System.out.print("register driver: Exception: " + e.getMessage()+"rn");
}
System.out.print("Loading driver...rn");
try { Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); }
catch(java.lang.ClassNotFoundException m)
{
System.out.print("class for name: Exception class not found: " + m.getMessage()+"rn");
}
catch(java.lang.InstantiationException m)
{
System.out.print("Instantiation Exception: " + m.getMessage()+"rn");
}
catch(java.lang.IllegalAccessException m)
{
System.out.print("Illegal Access: " + m.getMessage()+"rn");
}
System.out.print("Creating connection... rn");
try {
conn = DriverManager.getConnection(url);
System.out.print("Connected to " + getlblSvrName().getText() + ".rn");
getlblConStatus().setText("Connected to " + getlblSvrName().getText() + ".");
getButton6().setEnabled(true);
getButton2().setEnabled(true);
getButton5().setEnabled(false);
connected = true;
getlblConnTime().setText(myDateTime);
}
catch (Exception x) {
getlblErrStatus().setText("DriverManager.getConnection:" + x.getMessage());
System.out.print(url + ": no connection!rn");
x.printStackTrace();
getlblConStatus().setText("Not Connected.");
connected = false;
}
......
/////////////////////////////////////////////////////////////
Here is the print out and stack trace:
Registering driver...
Loading driver...
Creating connection...
jdbc:oracle:thin:scott/tiger@IQUEST_BOB:1521:IQORACLE: no connection!
java.lang.NullPointerException at oracle.jdbc.driver.OracleDriver.connectOracleDriver.java:342)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
...
/////////////////////////////////////////////////////////////////
ClassPath:
.;C:oracleora92jdbclibclasses12.jar;C:oracleora92jdbclibojdbc14.jar;
ANY HELP WOULD RECEIVE MY UPTMOST APPRECIATION AND UNDYING SUPPORT!! :)
Bobman
|
|
|