zzgf16
发贴: 6
|
于 2004-09-13 13:19
public Collection getMessage()throws Exception { Collection ret=new ArrayList(); try { Statement stm=con.createStatement(); ResultSet result=stm.executeQuery("select count from message"); int message_count=0; if(result.next()) { message_count=result.getInt(1);//返回message表里的所有记录数 result.close(); } if(message_count>0) { result=stm.executeQuery("select * from message order by time desc");//如果message表里有记录按时间time的降序排列 while(result.next()) { String title=result.getString("title");//String title定义错了,应该是name MessageVO message=new MessageVO(); message.setName(name); ret.add(message);//??如何理解:ret是ARRAYLIST型集合,它加入了MessageVO 的对象 } result.close(); stm.close(); } con.close(); } catch(Exception e) { e.printStackTrace(); throw e; } return ret;//??如何理解//返回ret这个集合,集合里包含着message表里title字段的名字的多个MessageVO对象 } 请大家批评指正,谢谢!!
|