日期:2014-05-17 浏览次数:20822 次
List<topic> topices = new ArrayList<topic>(); topices=topic.getTopic();
public static List<topic> getTopic() { List<topic> topices = new ArrayList<topic>(); Connection conn = DB.getConn(); String sql = "select * from topic"; Statement stmt = DB.getStatement(conn); ResultSet rs = DB.getResultSet(stmt, sql); try { while (rs.next()) { topic t = new topic(); t.setSid(rs.getInt("sid")); t.setUid(rs.getInt("uid")); t.setTitle(rs.getString("title")); t.setContent(rs.getString("content")); t.setPosttime(rs.getTimestamp("posttime")); t.setClickcount(rs.getInt("clickcount")); t.setLastreply(rs.getTimestamp("lastreply")); t.setIstop(rs.getBoolean("istop")); t.setIsgood(rs.getBoolean("isgood")); t.setLevel(rs.getInt("level")); topices.add(t); } } catch (SQLException e) { e.printStackTrace(); } finally { DB.close(rs); DB.close(stmt); DB.close(conn); } return topices; }