关于java,sql问题,急啊!
这是一个获取所有文章标题压栈到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是我的标题)
都是同一个记录,怎么回事啊,
------解决方案--------------------显示一下topicid看看