这是一个获取所有文章标题压栈到Vector里的功能代码.String strSql;
ResultSet rs;
Vector Topic = new Vector();
Topic topicform = new Topic();
strSql = "select topicid,topic,level,clicktimes from okancn_topic where sortid="+1 + " order by time DESC";rs = db.OpenSql(strSql);
while(rs.next()){
topicform.setTopicid(rs.getInt(1));
topicform.setTopic(rs.getString(2));
topicform.setLevel(rs.getInt(3));
topicform.setClicktimes(rs.getInt(4));
System.out.println("一次压栈"+rs.getString(2));
//压栈
Topic.addElement(topicform);
}
topicform = (Topic)Topic.get(0);
System.out.println("一次"+topicform.getTopic());
topicform= (Topic)Topic.get(1);
System.out.println("二次"+topicform.getTopic());比如我okancn_topic表里有两条不同记录
打印的结果怎么是"一次asdfasdf,二次asdfasdf" (asdfasdf是我的标题)
都是同一个记录,怎么回事啊,
ResultSet rs;
Vector Topic = new Vector();
Topic topicform = new Topic();
strSql = "select topicid,topic,level,clicktimes from okancn_topic where sortid="+1 + " order by time DESC";rs = db.OpenSql(strSql);
while(rs.next()){
topicform.setTopicid(rs.getInt(1));
topicform.setTopic(rs.getString(2));
topicform.setLevel(rs.getInt(3));
topicform.setClicktimes(rs.getInt(4));
System.out.println("一次压栈"+rs.getString(2));
//压栈
Topic.addElement(topicform);
}
topicform = (Topic)Topic.get(0);
System.out.println("一次"+topicform.getTopic());
topicform= (Topic)Topic.get(1);
System.out.println("二次"+topicform.getTopic());比如我okancn_topic表里有两条不同记录
打印的结果怎么是"一次asdfasdf,二次asdfasdf" (asdfasdf是我的标题)
都是同一个记录,怎么回事啊,
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货