你写得不完整,这个oracle.jdbc.driver.OracleDriver

解决方案 »

  1.   

    to  sailorbig(火冰山) 
       你写得那个我以前就试过了,我是出错了才改成这样的。
      

  2.   

    有没有加入oracle的package包啊?
      

  3.   

    package是什么包?,能否说得详细些?
      

  4.   

    你有没有在运行的的时候把class12导入啊?在oracle的jdbc/lib里边
      

  5.   

    to  sailorbig(火冰山) import oracle.jdbc.*;
     导了,是这样吧?  不过用jCreator连以上那句也不通过,出错信息:
      package oracle.jdbc.lib does not exist
    import oracle.jdbc.lib.*;
    ^
      

  6.   

    sorry 
      出错信息应该是:
      package oracle.jdbc.lib does not exist
    import oracle.jdbc.*;
    ^
      

  7.   

    好像不是吧,应该是在运行的时候加载class12.zip的路径,在你的盘里放在哪,就把绝对路径加进去,比如用IBM VisualAge for Java的话,就是目录重要运行的文件上,选择运行中的检查类路径,一般它的class12的默认路径不对,你要改掉
      

  8.   

    to sailorbig(火冰山) 
      你能不能用代码示例一下,谢谢!!!
      

  9.   

    import oracle.jdbc*;不能找到你的那个class12.zip或.jar所在的位置,所以会报错,你把它加上去试试看吧
      

  10.   

    加class12.zip的路径并不是写在程序里的,是要设置在运行的时候,在程序里不显示,比如我这个程序:
    package fjdd.PubClass;import java.sql.*;import javax.sound.sampled.BooleanControl;import org.omg.CORBA.Object;
    public class JustAConnect {
    String url="jdbc:oracle:thin:@127.0.0.1:1521:sailordb";
    String username="system";
    String password="manager";
    String driver="oracle.jdbc.driver.OracleDriver";
    String sql = "select * from tab";
    Connection conn=null;
    PreparedStatement abc=null;
    ResultSet res=null;
    String bo=null;
    Statement stm=null;

    private Connection Connect() {

    try{
    conn=DriverManager.getConnection(url,username,password);
        

    } catch(Exception e){
    System.out.println(e);

    }
    return conn;
    }
    // try{
    // Connection conn=DriverManager.getConnection(url,username,password);
    // }catch(Exception e)
    //     {
    //     System.out.println(e);
    //     }
    public PreparedStatement statement(String sql){
    try{
    abc=conn.prepareStatement(sql);
    }catch(Exception e){
    System.out.println("statement"+e);
    }
    return abc;
    }
    public String result(PreparedStatement abc){
    try{
    bo = Boolean.toString(abc.execute());

    }catch(Exception e){
    System.out.println("result"+e);

    }

    return bo;}
    public String execute(){
    try{
    String url="jdbc:oracle:thin:@127.0.0.1:1521:sailordb";
    String username="SAILOR";
    String password="SAILOR";
    String driver="oracle.jdbc.driver.OracleDriver";
    String sql = "select id from xd_cmd where title = 4 ";
    Connection conn=null;
    PreparedStatement abc=null;
    ResultSet res=null;
    ResultSetMetaData md=null;
    String bo=null;
    Statement stm=null;
    int a;
    int n=0;
        Class.forName(driver);
    conn=DriverManager.getConnection(url,username,password);
        stm = conn.createStatement();
        res = stm.executeQuery(sql);
        while (res.next()){n++;
         a = res.getInt("id");
         System.out.println("id("+n+")="+a);
        
        };
    //     md = res.getMetaData();
    //     n = md.getColumnCount();
    //     for(int i=1;i<n+1;i++){
    //      System.out.println(res.getObject(i));
    //     
    //     }
        
    //     System.out.println(res);

    } catch(Exception e){
    System.out.println(e);

    }
    return null;

    }
    public static void main(String[] args){
    JustAConnect test = new JustAConnect();
    test.execute();

    }
    }
    并没有import oracle.jdbc*;
    但要在运行前设定class12.zip的路径,在IBM VisualAge for Java的话,就是目录重要运行的文件上,选择运行中的检查类路径,在togertherWSE就是设置属性,然后才能联接的通,不然就报错
      

  11.   

    如果不用任何其它工具,只用JDK开发,应该怎样设置?
      

  12.   

    在jb下导入oracle的jcbc的驱动在加上你那句话import oracle.jdbc.*;就可以了,但在jdk下没做过应该能你搜一下吧.