在eclipse中用JDBC连接oracle数据库总是提示Exception in thread "main" java.lang.ClassNotFoundE
这是代码:
import java.sql.*;
public class testoracle2 {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
// TODO Auto-generated method stub
Class.forName("oralce.jdbc.driver.OracleDriver");
Connection ct=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","zys");
Statement st=ct.createStatement();
ResultSet rt=st.executeQuery("select * from emp");
while(rt.next()){
System.out.println("用户名:"+rt.getString(2));
}
rt.close();
st.close();
ct.close();
}
}
------解决方案-------------------- oralce.jdbc.driver.OracleDriver
把包名写对了再说。
不会写就 直接把第一行换成
OracleDriver o = new OracleDriver();
起码编译器能帮你找错。
------解决方案--------------------
顶楼上,仔细比较下边两行代码:
oralce.jdbc.driver.OracleDriver
oracle.jdbc.driver.OracleDriver