System.out.println(i);
这句话输出为: 0 
我少写了 不好意思
请大狭帮忙看看

解决方案 »

  1.   

    if(st.next()){
    改成
    while(st.next()){
      

  2.   

    我改了
    但是还是少一组数据啊
    输出结果如下:
    30.0
    true
    15.0
    true
    15.0
      

  3.   

    你在每次循环里执行了两次st.next()!
    if(st.next())改成while(st.next())
    整个程序这样改 String sql="select goodsname,introduction,unit,company,price,total from goods ";
    st=cql.executeQuery(sql);
    while(st.next())
    System.out.println(i);
    goodsname[i]=st.getString("goodsname");
    unit[i]=st.getString("unit");
    introduction[i]=st.getString("introduction");
    company[i]=st.getString("company");
    price[i]=st.getString("price");
    System.out.println(price[i]);
    total[i]=st.getString("total");
    i++;
    System.out.println(true);
          }你在while的时候已经判断了st.next()为true才执行后面的代码,在循环的时候直接输出true就行了,这样说明白了不?
      

  4.   

    想要知道st什么时候next不下去,那么在while的后面跟上一个System.out.println(false);就OK了
      

  5.   

    去掉   System.out.println(st.next()); 
      

  6.   

    while(rs.next())
    {
    read.......data.......
    }