Exemplo n.º 1
0
 public int upatePost(Post post) {
   int count = 0;
   try {
     count = executeUpdate(ReflectUtil.reflect(post, true));
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     closeConn();
   }
   return count;
 }
Exemplo n.º 2
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.º 3
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;
 }
Exemplo n.º 4
0
 public int newPost(Post post) {
   int pid = -1;
   try {
     int count = executeUpdate(ReflectUtil.reflect(post, false));
     if (count == 1) {
       ResultSet rs = executeSQL("select LAST_INSERT_ID()");
       rs.next();
       pid = rs.getInt(1);
     }
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     closeConn();
   }
   return pid;
 }