I am using jdk1.4.
I have copied ojdbc14.jar to C:\j2sdk\jre\lib\ext and I can compile Employee.java successfully.
But when I run Employee, got error as
'Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver
So I run
jar -xvf ojdbc14.jar,
to extract oracle folder inside ojdbc14.jar and copy it to my current working place then I can run Employee, if I delete the oracle folder (which is extracted from ojdbc14.jar) from the current working folder, it won't work again!
I couldn't find out what is wrong, anyone has any idea?
The following is Employee.java
* This sample shows how to list all the names from the EMP table
* It uses the JDBC THIN driver. See the same program in the
* oci8 samples directory to see how to use the other drivers.
// You need to import the java.sql package to use JDBC
public static void main (String args )
// Load the Oracle JDBC driver
// Connect to the database
// You must put a database name after the @ sign in the connection URL.
// You can use either the fully specified SQL*net syntax or a short cut
// syntax as <host>:<port>:<sid>. The example uses the short cut syntax.
//String url = "jdbc
//String userName = "nan";
//String password = "nan";
String url = "jdbc
String userName = "scott";
String password = "tiger";
if (args.length > 0) url = args;
if (args.length > 1) userName = args;
if (args.length > 2) password = args;
Connection conn =
DriverManager.getConnection (url, userName, password);
// Create a Statement
Statement stmt = conn.createStatement ();
// Select the ENAME column from the EMP table
ResultSet rset = stmt.executeQuery ("select ENAME from EMP");
// Iterate through the result and print the employee names
while (rset.next ())
System.out.println (rset.getString (1));
[ April 05, 2003: Message edited by: nan sh ]