-1
import java.sql.*;  
class OracleCon{  
public static void main(String args[]){  
try{  
//step1 load the driver class  
Class.forName("oracle.jdbc.driver.OracleDriver");  

//step2 create  the connection object  
Connection con=DriverManager.getConnection(  
"jdbc:oracle:thin:@localhost:1521:xe","scott","tiger");  

//step3 create the statement object  
Statement stmt=con.createStatement();  

//step4 execute query  
ResultSet rs=stmt.executeQuery("select * from emp");  
while(rs.next())  
System.out.println(rs.getInt(1)+"  "+rs.getString(2)+"  "+rs.getString(3));  

//step5 close the connection object  
con.close();  

}catch(Exception e){ System.out.println(e);}  

}  
}  

and the error is

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

I'm unaware of connecting to localhost.

halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

0

The error seems to be in your JDBC driver class registration. Make sure you have driver-jar included in your library. You can also refer this

Stkuser
  • 1
  • 1