数据操作通用类里有个方法
public ResultSet executeQuery(String sql) throws SQLException, ClassNotFoundException
    {
     String strDriver="oracle.jdbc.driver.OracleDriver";
     String strConn="jdbc:oracle:thin:@127.0.0.1:1521:test";
     String dbUser="system";
     String dbPwd="123456";
     Connection connSet = null;
        ResultSet rsSet=null;
        Statement stmtSet=null;
        rs=null;
        try
        {
         Class.forName(strDriver);   
         connSet=DriverManager.getConnection(strConn,dbUser,dbPwd);
         stmtSet=connSet.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
         rsSet=stmtSet.executeQuery(sql);
            
        }
        catch(SQLException ex)
        {
            System.err.println("sql_data.executeQuery:"+ex.getMessage());
            stmtSet.close();
            stmtSet=null;
            rsSet.close();
            rsSet=null;
            connSet.close();
            connSet=null;
        }
        return rsSet;   
    }JSP里调用
                   String nlTitle="";
String nlId="";
   String TempCataStr="";
   Fun_DB_WEB dbfun=new Fun_DB_WEB();
   rs=dbfun.executeQuery("select new_class_title,new_class_id from news_class where new_class_isdel=0 order by new_class_id");
   try{
   while (rs.next())
   {
   nlTitle=rs.getString("new_class_title");
   nlId=rs.getString("new_class_id");
   TempCataStr = TempCataStr+"<img src='images/left_img/join.gif'><a href=newclass.jsp?RootId="+nlId+">"+nlTitle+"</a><br>";
   }
   System.err.println("得到栏目:"+nlTitle+"ID:"+nlId+"数据库标题:"+rs.getString("new_class_title"));
  
   }
   catch(SQLException ex)
   {
  
   System.err.println("获取栏目出错:"+ex);
   }
为什么老报 : 获取栏目出错:java.sql.SQLException: 结果集已耗尽
大侠们帮我看看吧,分不够,再加!

解决方案 »

  1.   

    while(rs.next()) 退出后,结果集游标已到达末尾,你还调用
    rs.getString("new_class_title"),就会发生异常。
      

  2.   

    System.err.println("得到栏目:"+nlTitle+"ID:"+nlId+"数据库标题:"+rs.getString("new_class_title")); 这一句不对
    还有 你没有关闭RS,CONN也有问题
      

  3.   

    你最后没有关闭rs呀,你再仔细看看,打开了rs肯定要关闭的呀,不关闭应该会用尽的呀
      

  4.   

     while   (rs.next()) 
        { 
        nlTitle=rs.getString("new_class_title"); 
        nlId=rs.getString("new_class_id"); 
        TempCataStr   =   TempCataStr+" <img   src='images/left_img/join.gif'> <a   href=newclass.jsp?RootId="+nlId+"> "+nlTitle+" </a> <br> "; 
        } //位置不对吧??    
    System.err.println("得到栏目:"+nlTitle+"ID:"+nlId+"数据库标题:"+rs.getString("new_class_title")); 
    //}是不是应该放在这里呢?,不要两次都取同一个字段,直接用nlTitle就可以了
        
      

  5.   

    while       (rs.next())   
            {   
            nlTitle=rs.getString("new_class_title");   
            nlId=rs.getString("new_class_id");   
            TempCataStr       =       TempCataStr+"   <img       src='images/left_img/join.gif'>   <a       href=newclass.jsp?RootId="+nlId+">   "+nlTitle+"   </a>   <br>   ";   
            }   //位置不对吧??         
    System.err.println("得到栏目:"+nlTitle+"ID:"+nlId+"数据库标题:"+rs.getString("new_class_title"));   
    //}是不是应该放在这里呢?,不要两次都取同一个字段,直接用nlTitle就可以了 
      

  6.   


      try{
        while (rs.next()) { 
          nlTitle=rs.getString("new_class_title"); 
          nlId=rs.getString("new_class_id"); 
          TempCataStr = TempCataStr+" <img src='images/left_img/join.gif'> <a href=newclass.jsp?
            RootId="+nlId+"> "+nlTitle+" </a> <br> "; 
          System.err.println("得到栏目:"+nlTitle+"ID:"+nlId+"数据库标题:"+nlTitle; 
        }
      } 
      catch(SQLException ex) { 
        System.err.println("获取栏目出错:"+ex); 
      }
      

  7.   

    为什么老报   :   获取栏目出错:java.sql.SQLException:   结果集已耗尽
     conn连接没有关闭,你Fun_DB_WEB   dbfun=new   Fun_DB_WEB(); 
    建立一个连接,当然会耗尽结果集了,建议代码写的规范些
    如:
      JSP里调用 
                                        String   nlTitle=""; 
    String   nlId=""; 
        String   TempCataStr=""; 
        Fun_DB_WEB   dbfun=new   Fun_DB_WEB(); 
        rs=dbfun.executeQuery("select   new_class_title,new_class_id   from   news_class   where   new_class_isdel=0   order   by   new_class_id"); 
        try{ 
        while   (rs.next()) 
        { 
        nlTitle=rs.getString("new_class_title"); 
        nlId=rs.getString("new_class_id"); 
        TempCataStr   =   TempCataStr+" <img   src='images/left_img/join.gif'> <a   href=newclass.jsp?RootId="+nlId+"> "+nlTitle+" </a> <br> "; 
        } 
        System.err.println("得到栏目:"+nlTitle+"ID:"+nlId+"数据库标题:"+rs.getString("new_class_title")); 
        
        } 
        catch(SQLException   ex) 
        { 
        
        System.err.println("获取栏目出错:"+ex); 
        } 
      //增加如下内容,具体的conn以程序中的对应  
       finally{
     
        try{
          if(rs!=null) {
                rs.close();
               }
          if(conn!=null){
                conn.close();
             }
          }
       catch (Exception e1) {
       e1.printStackTrace();
    }
    }