关于java中的Result对象

qilong450457412 2012-04-23 10:43:17
查询Oracle数据库得到的结果集存到ResultSet里面,然后转存到Result对象里返回后如何获取int类型的数据???
...全文
260 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]

用对象的 getInt(int columnIndex) 或getInt(String columnName) 方法。 (columnIndex 从1开始)。
[/Quote]

while(rs.next()){

int temp = rs.getInt(数据库列名【String】);

}

or

while(rs.next()){
int temp = rs.getInt(数据库第几列【int】)
}


最后在关闭
nmyangym 2012-04-23
  • 打赏
  • 举报
回复
用对象的 getInt(int columnIndex) 或getInt(String columnName) 方法。 (columnIndex 从1开始)。
五哥 2012-04-23
  • 打赏
  • 举报
回复
System.out.println("有" + result.getRowCount() + "条记录!!!");
for(int i=0;i<result.getRowCount();i++)

{

Map map=result.getRows()[i]; //每次循环定位到一条记录

System.out.println(map.get("字段1")+" "+map.get("字段2"));

}



拿到在强制转换不行 ?
cxw3152 2012-04-23
  • 打赏
  • 举报
回复
getInt(String columnName)

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧