0

ClassNotFoundException:OracleDriver在 Win7 32 位上与 Oracle 11g express db 的 JDBC 连接

源代码在这里:

import java.lang.*;
import java.sql.*;

class OracleCon{
public static void main(String args[])
   {
        try{
              Class.forName("oracle.jdbc.driver.OracleDriver");
              Connection con=DriverManager.getConnection(
              "jdbc:oracle:thin:@localhost:1521:xe","system","ashish");
               Statement stmt=con.createStatement();
                ResultSet rs=stmt.executeQuery("select * from emp");
             while(rs.next())
               System.out.println(rs.getInt(1)+"  "+rs.getString(2)+"  "+rs.getString(3));
              con.close();
             }catch(Exception e)
                      { 
                         System.out.println(e);
                       }
      }
}

在运行此程序代码之前,我使用以下命令设置路径:

path c:\Program Files\Java\jdk1.7.0_25\bin 
set classpath=c:\program fles\Java\jre7\lib\ojdbc14

当我通过 cmd(命令提示符)运行此源代码时,我得到以下输出:

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

0 回答 0