Posted By:
david_wang
Posted On:
Monday, January 28, 2002 07:38 AM
I'm new to VisualAge for Java. My Windows 2000 machine has VAJ 3.5.3 and Oracle 9i. I have been trying to run a simple program to test the JDBC connection. import java,sql.*; Public class TestJDBC { public static void main(String[] args){ try{ Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con = DriverManager.getConnection ("jdbc:oracle:thin:@myHost:myPort:mySource", "user", "password"); PreparedStatement stmt = con.prepareStatement("Select * from aTable"); ResultSet rs = stmt.executeQuery(); // process the result set rs .... con.close } catch(Exception e){ Syst
More>>
I'm new to VisualAge for Java. My Windows 2000 machine has VAJ 3.5.3
and Oracle 9i. I have been trying to run a simple program to test the
JDBC connection.
import java,sql.*;
Public class TestJDBC {
public static void main(String[] args){
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection
("jdbc:oracle:thin:@myHost:myPort:mySource", "user", "password");
PreparedStatement stmt = con.prepareStatement("Select * from
aTable");
ResultSet rs = stmt.executeQuery();
// process the result set rs ....
con.close
} catch(Exception e){ System.err.println(e);
}
}
}
Before I run the code, I have followed the instruction to add the
location of JDBC driver to the
workspace's classpath. The path is in Oracle9i folder "Oracle9i_HOMEjdbclibclasses12.jar;" But every time I get a SQLException "No
suitable driver."
Did I add the wrong driver? The README doc that comes with Oracle9i
clearly states that this is the classes use with JDK 1.2.*. I have
replaced it with .zip file, or even classes112.jar/zip, which is
classes for jdk1.1.*, and still got the same exception. I went to
oracle.com, but only found Oracle8i 8.1.7 JDBC drivers. Can someone
shed some light on this problem? Any help is greatly appreciated.
<<Less