Exemplo n.º 1
0
 public static boolean addSharedList(SharedList list) {
   String sql =
       "INSERT INTO `greenlife`.`shared_list` "
           + "(`wechat_id`, `friend_wechat_id`, `goods_id`) VALUES (?, ?, ?);";
   Connection conn = new DBUtil().getConn();
   try {
     ps = conn.prepareStatement(sql);
     ps.setString(1, list.getWechatId());
     ps.setString(2, list.getFirendWechatId());
     ps.setInt(3, list.getGoodsId());
     ps.execute();
   } catch (SQLException e) {
     e.printStackTrace();
     return false;
   } finally {
     clearUp(conn);
   }
   return true;
 }
Exemplo n.º 2
0
 public static boolean updateSharedList(SharedList list) {
   String sql =
       "UPDATE `greenlife`.`shared_list` SET "
           + "friend_wechat_id = (?) "
           + "goods_id = (?)"
           + "WHERE wechat_id = (?);";
   Connection conn = new DBUtil().getConn();
   try {
     ps = conn.prepareStatement(sql);
     ps.setString(1, list.getFirendWechatId());
     ps.setInt(2, list.getGoodsId());
     ps.setString(3, list.getWechatId());
     ps.execute();
   } catch (SQLException e) {
     e.printStackTrace();
     return false;
   } finally {
     clearUp(conn);
   }
   return true;
 }