コード例 #1
0
  public void SaveUserChangesToDB() {
    // TODO Auto-generated method stub
    String sql =
        "update usersdata "
            + "set First_Name = '"
            + ud.first_name
            + "', "
            + "Last_Name = '"
            + ud.last_name
            + "', "
            + "Email = '"
            + ud.email
            + "', "
            + "CC_Number = '"
            + ud.cc_number
            + "', "
            + "Expiration_Date = "
            + ud.expiration_date
            + ", "
            + "Security_Code = "
            + ud.security_code
            + ", "
            + "Phone = '"
            + ud.phone
            + "' "
            + "where user_id = "
            + ud.user_id
            + ";";
    Utils.executeNonQuery(sql);

    System.out.println("User information changed.");
    System.out.println("user_id: " + ud.user_id);
    System.out.println("Name: " + ud.first_name + " " + ud.last_name);
    System.out.println("Email: " + ud.email);
  }
コード例 #2
0
  private void SaveUserToDB() {
    // TODO Auto-generated method stub
    String sql =
        "insert into usersdata (First_Name, Last_Name, Email, CC_Number, Expiration_Date, Security_Code, Phone) "
            + "values ('"
            + ud.first_name
            + "', '"
            + ud.last_name
            + "', '"
            + ud.email
            + "', '"
            + ud.cc_number
            + "', "
            + ud.expiration_date
            + ", "
            + ud.security_code
            + ", '"
            + ud.phone
            + "');";

    int new_user_id = Utils.executeNonQuery(sql);
    if (new_user_id > 0) {
      System.out.println("user_id: " + new_user_id);
      System.out.println("Name: " + ud.first_name + " " + ud.last_name);
      System.out.println("Email: " + ud.email);
      System.out.println("Date Created: " + Utils.GetTodayDateTime());
    } else System.out.println("Invalid User information");
  }