关于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;
}