该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
代码:
package com.sp;
import java.sql.*;
//演示JDBC连接
public class OraDemo2 {
public static void main(String[] args) throws ReflectiveOperationException, SQLException {
// TODO Auto-generated method stub
//1.加载驱动
Class.forName("Oralce.jdbc.driver.OracleDriver");
//2.得到连接
Connection ct = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.103:1158:ORCL","scott","330328");
Statement sm = ct.createStatement();
ResultSet rs = sm.executeQuery("select * from emp");
while(rs.next()){
System.out.println("用户名:"+rs.getString(2));
}
}
}
报错:
Exception in thread "main" java.lang.ClassNotFoundException: Oralce.jdbc.driver.OracleDriver
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.sp.OraDemo2.main(OraDemo2.java:11)