public ResultSet getData(String tablename,String condition,int pagesize,int currentpage)
{//分页送显数据的方法
try
     {
     String sql = "";
     sql = "select top "+pagesize+" * from "+tablename+
" where id not in(select top "+pagesize*(currentpage-1)+
" id from "+tablename+" where 1=1 "+
(condition==""?"":(" and "+condition))+")"+(condition==""?"":(" and "+condition));
     stat = con.createStatement();
         rs = stat.executeQuery(sql);
     }
     catch(Exception e){
     System.out.println(rs);
     System.out.println("查询失败dbcon");
     }
     return rs;
}
为啥rs返回null啊  谢谢了

解决方案 »

  1.   

    System.out.println(sql);
    看看sql能执行出结果么?
    这类问题一般都是由于粗心导致的小问题。
      

  2.   

    你先把SQL语句写简单点,看看是SQL语句错了还是con的问题。
      

  3.   

    sql的结果是 
    select top 100 * from ryb where id not in(select top 0 id from ryb where 1=1 and user='' and password='') and username='' and password=''
      

  4.   

    把sql语句打印出来,去sql console执行  就知道了
      

  5.   

    select top 0?
    有点意思。
      

  6.   


    select top 100 * from ryb where id not in(select top 0 id from ryb where 1=1 and user='' and password='') and username='' and password=''在sqlserver中将参数带进去看看有没有数据。。我忘记top从0还是1开始的了
      

  7.   

    给你一句好用的 select * from (" +
    "select *,row_number() over(order by qs_code) rn "+
    "from TEST.QS) a where rn between ? and ?";
      

  8.   

    student ----  user  
    teacher  -----  ryb 
      

  9.   

    这不是oracle里面的分页查询吗。
      

  10.   

    你用的是salserver2005?还是2000,2005对这种top好像不是很支持