Hi I am new to java when I tried to connect oracle with my java sample code I got the above exception
My Code is
import java.sql.*;
import java.io.IO
package testing;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.*;
public class OracleJDBC {
public static void main(String[] argv) {
System.out.println("-------- Oracle JDBC Connection Testing ------");
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (ClassNotFoundException e) {
System.out.println("Where is your Oracle JDBC Driver?");
e.printStackTrace();
return;
}
System.out.println("Oracle driver registered");
Connection conn=null;
try {
conn = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:orclh", "scott",
"tiger");
Statement stmt= conn.createStatement();
ResultSet r=stmt.executeQuery("Select * from emp");
while(r.next()){
String str= r.getString("ename");
System.out.println (str);
}
} catch (SQLException e) {
System.out.println("Connection Failed! Check output console");
e.printStackTrace();
return;
}
}
}