当前位置: 代码迷 >> Eclipse >> eclipse 连接 oracle 9i,该如何处理
  详细解决方案

eclipse 连接 oracle 9i,该如何处理

热度:496   发布时间:2016-04-23 14:52:19.0
eclipse 连接 oracle 9i
package   zhang;
import   java.sql.*;
//import   oracle.jdbc.driver.*;
public   class   Test   {


public   static   void   main(String[]   args)     {  

    java.sql.Connection   conn=null;
    try
    {
    Class.forName( "oracle.jdbc.driver.OracleDriver ");
    conn   =DriverManager.getConnection( "jdbc.oracle.thin:@192.168.18.11:1521:prod_11 ", "apps ", "apps ");
    Statement   stmt=conn.createStatement();
    ResultSet   rs=stmt.executeQuery( "select   *   from   exnbt.unitstore ");
    while   (rs.next())
    {
  System.out.print(rs.getString(1));  
    }
  //   System.out.println( "successful! ");
    }
    catch   (Exception   e){
    System.out.println( "Error "+ "--- "+e.getMessage());
   
    }

}
}
这是连接oracle的代码,我把classes12.jar   添加到了classpath,项目中我也导入了classes12.jar,为什么还会报错:Error---No   suitable   driver

------解决方案--------------------
在eclipse下,你要把驱动的那个JAR增加到java bulid path里
------解决方案--------------------
( "jdbc.oracle.thin:@192.168.18.11:1521:prod_11 ", "apps ", "apps ");
______^____
改为:( "jdbc:oracle:thin:@192.168.18.11:1521:prod_11 ", "apps ", "apps ");
___________^____
晕倒,多检查两遍就可以避免的错误
  相关解决方案