jsp中如何把ResultSet rs中的结果放入list中再循环取出呢?
Stringmno=request.getParameter("mno");Stringsql="selectseatnofromseatchoosewheremno='...
String mno=request.getParameter("mno");
String sql="select seatno from seatchoose where mno='"+mno+"'";
ResultSet rs=SQLHelper.executeQuery(sql);
请教下接下去该怎么写 展开
String sql="select seatno from seatchoose where mno='"+mno+"'";
ResultSet rs=SQLHelper.executeQuery(sql);
请教下接下去该怎么写 展开
2个回答
展开全部
1.
List list = new ArrayList();
try {
rs = ps.executeQuery();
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
while(rs.next()){
for(int i=1;i<=columnCount;i++){
//这里也可以放到MAP里面
String columnName = rsmd.getColumnName(i);
Object value = rs.getObject(i);
list.add(columnName+":"+value);
}
}
} catch (Exception e) {
// TODO: handle exception
}
List list = new ArrayList();
try {
rs = ps.executeQuery();
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
while(rs.next()){
for(int i=1;i<=columnCount;i++){
//这里也可以放到MAP里面
String columnName = rsmd.getColumnName(i);
Object value = rs.getObject(i);
list.add(columnName+":"+value);
}
}
} catch (Exception e) {
// TODO: handle exception
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询