public Post getPostById(String pid) { String sql = "select * from t_post where pid =" + pid; ResultSet rs = executeSQL(sql); Post post = null; try { if (rs.next()) { post = (Post) ReflectUtil.fillData(new Post(), rs); } } catch (Exception e) { e.printStackTrace(); } finally { closeConn(); } return post; }
public List<Post> getPostList(int index, int num) { String sql = "SELECT * from t_post order by pid desc LIMIT " + index + "," + num; ResultSet rs = executeSQL(sql); List<Post> list = new ArrayList<Post>(); try { while (rs.next()) { list.add((Post) ReflectUtil.fillData(new Post(), rs)); } } catch (Exception e) { e.printStackTrace(); } finally { closeConn(); } return list; }