【问题标题】:Where do I put my driver files for JDBC?我在哪里放置 JDBC 驱动程序文件?
【发布时间】:2018-11-30 23:03:06
【问题描述】:

我正在尝试连接到 oracle xe 11g 服务器 (11.2),当我尝试运行我的程序时,我收到错误消息:

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

我已经安装了 ojdbc7,它与我的 connect.class 和 connect.java 文件都在污染区。我究竟做错了什么?抱歉,这是补救措施,是 oracle 的新手。

 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","system","oracle");  

    //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);}  

    }  

【问题讨论】:

    标签: oracle jdbc oracle11g


    【解决方案1】:

    已解决。我需要将驱动程序添加到我的构建路径中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-10
      • 1970-01-01
      • 2015-06-26
      • 2014-08-31
      • 2012-10-21
      • 1970-01-01
      • 1970-01-01
      • 2011-07-15
      相关资源
      最近更新 更多