关于list添加字符串的问题
怎么样用list 添加查询出来的字符串比如
public class HoldDaoImpl implements IHoldDao {
//通过用户的名字得到用户所买的股票名字
public List getUserHolding(int userid) {
Connection conn=null;
PreparedStatement pst=null;
ResultSet rs=null;
List list=new ArrayList();
try{
conn=ConnectionFactory.getConnection();
String sql="select name from stock where stock_id=(" +
"select stock_id from holding where user_id=?)";
pst=conn.prepareStatement(sql);
pst.setInt(1, userid);
rs=pst.executeQuery();
while(rs!= null && rs.next()){
这里怎样用list添加查询出来的name值
??????
??????
}
}catch(Exception e){
e.printStackTrace();
}finally{
ConnectionFactory.closeResultSet(rs);
ConnectionFactory.closePreparedStatement(pst);
ConnectionFactory.closeConnection(conn);
}
return list;
}
搜索更多相关主题的帖子:
list 字符
----------------解决方案--------------------------------------------------------
各位大虾帮帮忙
----------------解决方案--------------------------------------------------------
用list.add()方法
----------------解决方案--------------------------------------------------------
list.add只能加对象吧,我试了eclipse 一直报错
----------------解决方案--------------------------------------------------------
list.add(new String(rs.getString(1)));
----------------解决方案--------------------------------------------------------