ClassNotFoundException: oracle.jdbc.driver.OracleDriver
Dear All:
I have some problems on using Oracle JDBC Driver.
I have downloaded classes12.zip and nls_charset12.zip and set
the class path as [ORACLE_HOME]\jdbc\lib\classes12.zip and
[ORACLE_HOME]\jdbc\lib\nls_charset12.zip and added [ORACLE_HOME]
\jdbc\lib to the PATH. Also I have installed Oracle8i Client
8.1.5.0.0. Then I tried to compile a simple java program.
However, these errer messages occured when i run the program:
ClassNotFoundException: oracle.jdbc.driver.OracleDriver
Exception in thread "main" java.sql.SQLException: No suitable
driver
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at JdbcTest.main(JdbcTest.java:16)
The following is the program code:
import java.sql.*;
class JdbcTest {
public static void main (String args []) throws SQLException
{
// Load Oracle driver
try {System.out.println("line7");
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}System.out.println("line12");
// Connect to the local database
Connection conn = DriverManager.getConnection
("jdbc:oracle:oci8:@128.128.152.189:1521:ORCL","xxx", "xxx");
// Query the employee names
Statement stmt = conn.createStatement ();
ResultSet rset = stmt.executeQuery ("SELECT ename FROM emp");
// Print the name out
while (rset.next ())
System.out.println (rset.getString (1));
//close the result set, statement, and the connection
rset.close();
stmt.close();
conn.close();
}
}
why the program can't find the jdbc driver, as i have followed
the setting from the readme doc.
Thanks very much