I am trying to make a connection with a Oracle 9i server. I have a home network of three Pcs, with ip 192.168.1.2, 1.3. and 1.4 respectivly. I have the oracle server installes on the 1.3 ip and I am trying to connect from the 1.2 PC to the Oracle server but it gives me some problems. I am trying through the SQL PlusWorkshear and it works. I can work on the database, but through the Java Application created I can not. This is the code from the application:
import java.sql.*; public class ConnectionThin_1 {
/** Creates a new instance of Connection */ public ConnectionThin_1() { } public static void main(String[] args) { // System.out.println("PROBLEM"); //int i; Connection conn = null;
// register jdbc driver try{ Class.forName("oracle.jdbc.driver.OracleDriver"); // in order to use Oracle thin/oci driver
// connect to DB try{ // DriverManager.registerDriver(Driver OracleDriver); conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:katarina","scott","tig er"); System.out.println("PROBLEM"); // System.out.println(conn); // thin: driver // @127.0.0.1 for local connection. @xxx.xxx.xxx.xxx for global // 1521: port number. This should be match to Oracle network port. // datacafe: SID of Oracle database // scott: username of Oracle database // tiger: password of Oracle database
} catch(SQLException se) { System.out.println(se); System.out.println("connection is successful!!!"); }
And it gives me this error: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver java.sql.SQLException: No suitable driver connection is successful!!! java.lang.NullPointerException at ConnectionThin_1.main(ConnectionThin_1.java:56) Exception in thread "main"
Set the classes12.zip file in your classpath. Also remove the system.out from the exception or atleast chenge the text. Currently, it says connection is successful, which is wrong.
hi, as mentioned in your reply to add the classes12.zip in classpath..u mean in which folder..like i have only j2sdk1.4 installed on my local machine and oracle 9i on remote server..i have been trying to include the zip file in bin,jre\lib,jre\bin folders and set the classpath , but could not get the answer..do u have any suggestion for the problem..if so please send me the path..its very urgent ..