Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 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;
 }