将opendb包的完整路径加入到系统环境变量classpath里去就可以了

解决方案 »

  1.   

    你的opendb.java有没有package opendb;
    如果有应该不会出错。
      

  2.   

    To :beyond_xiruo
    我在环境变量里设置了
    在系统变量的classpath中添加了opendb包前的完整路径
    可还是提示opendb 包不存在
    设置完,应该不需要重启计算机吧
    to:frean
    opendb.java有 package opendb;并且通过编译
      

  3.   

    我认为应该在同一个工程里边编译会更方便一些,那样他会识别出来opendb也是自己编制的一个class,否则任何的独立引用都会让编译器在编译运行是找不到这个包!尽管在运行时能够调用到这个class
      

  4.   

    请问miwu:你是什么意思?同一个工程?
    你是说我把ques.class 也放在opendb包中吗?
    我现在只需创建一个beans 备用,而这个beans需要opendb中的class 文件的支持
      

  5.   

    在你的工程里面也加入ques.class所在的包
      

  6.   

    我就是要用JSP做一个网上在线考试系统,能自动从试题库中生成试题,并且在客户端每次只显示一份卷中的一个试题;而我的ques.class旨在从问题卷中取出要显示的题的相关内容,而opendb.class 是一个数据库接口,所以我需要在ques.class引入opendb包中的opendb.class文件
      

  7.   

    try{
    try{rs.next();
    Id=rs.getInt("ID");
    type=rs.getInt("Type");
    content=rs.getString("Content");
    count=rs.getInt("Count");
    rs.close();}
    catch(SQLException e){
    System.out.println("Database Error");
    }
    我的数据库中有一条满足条件"ID=1"的记录,可是老提示ArrayIndexOutOfBoundsException 1>=1
      

  8.   

    public Ques( int qID){
    opendb mydb=new opendb();
    String sql="select ID,Type,Content,Count from Question where  ID='"+qID+"'";
    System.out.println(sql);
    ResultSet rs=mydb.executeQuery(sql);
    try{
    rs.next();
    Id=rs.getInt("ID");
    type=rs.getInt("Type");
    content=rs.getString("Content");
    count=rs.getInt("Count");
    rs.close();}
    catch(SQLException e){
    System.out.println("Database Error");
    }
    }后来我创建了一个qID=1的对象
    我的数据库中有一条满足条件"ID=1"的记录,可是老提示ArrayIndexOutOfBoundsException 1>=1
      

  9.   

    按beyond_xiruo
    的解决办法成功解决上述问题
    将opendb包的完整路径加入到系统环境变量classpath里去就可以了