太奇怪了, 这是怎么回事啊?!!!!!!!!!!!!1 System.out.println(i);这句话输出为: 0 我少写了 不好意思请大狭帮忙看看 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 if(st.next()){改成while(st.next()){ 我改了但是还是少一组数据啊输出结果如下:30.0true15.0true15.0 你在每次循环里执行了两次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就行了,这样说明白了不? 想要知道st什么时候next不下去,那么在while的后面跟上一个System.out.println(false);就OK了 去掉 System.out.println(st.next()); while(rs.next()){read.......data.......} 请问如何改变j2se游戏中音乐音量,坐等。。 java统计txt文件内的中英文字数问题 c#转java,这段代码是什么意思呢,【急切】 编写应用程序,输出以下的菱形 swing焦点问题,谢谢 麻烦高手啊 那位大哥帮忙讲解一下JDK1.5 新式循环写法! 关于instanceof ad hoc query怎么翻译?是什么英文的缩写? 在java如何区分本地硬盘分区与网络映射硬盘分区 jtree中怎样屏蔽掉F2键的编辑功能 请问后缀是.pdg的文件用什么打开!
改成
while(st.next()){
但是还是少一组数据啊
输出结果如下:
30.0
true
15.0
true
15.0
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就行了,这样说明白了不?
{
read.......data.......
}