| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1236 人关注过本帖
标题:这两段结果集的代码运行后为什么有不同的结果?
只看楼主 加入收藏
mojiethebest
Rank: 2
等 级:论坛游民
帖 子:3
专家分:10
注 册:2019-5-30
收藏
 问题点数:0 回复次数:0 
这两段结果集的代码运行后为什么有不同的结果?
说明:rs为从数据库查询后返回的结果集,包含2行数据。
代码1:
Vector rowData=new Vector();
while(rs.next()){
    Vector currentRowData=new Vector();
    currentRowData.addElement(rs.getString(1);
    currentRowData.addElement(rs.getString(2);
    currentRowData.addElement(rs.getString(3);
    currentRowData.addElement(rs.getDouble(4);
   
    rowData.addElement(currentRowData);
}
System.out.println(rowData);

代码2:
Vector rowData=new Vector();
while(rs.next){
    rowData.addElement(getCurrentRowData(rs));
}
 System.out.println(rowData);


public static Vector getCurrentRowData(ResulSet rs){
    Vector currentRowData=new Vector();
    currentRowData.addElement(rs.getString(1);
    currentRowData.addElement(rs.getString(2);
    currentRowData.addElement(rs.getString(3);
    currentRowData.addElement(rs.getDouble(4);

    return curreentRowData;
}
搜索更多相关主题的帖子: 代码 运行 new Vector 结果 
2019-12-13 15:15
快速回复:这两段结果集的代码运行后为什么有不同的结果?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014243 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved