示例#1
0
  public List<User> getData(String selectSql) {
    System.out.println(selectSql);
    List<User> list = null;
    Pool pool = null;
    Connection conn = null;
    Statement stmt = null;
    try {
      pool = Pool.getInstance();
      conn = pool.getConnection();
      stmt = conn.createStatement();
      ResultSet rs = stmt.executeQuery(selectSql);
      list = new ArrayList<User>();
      User user = null;

      while (rs.next()) {
        user = new User();
        user.setAddress(rs.getString("ADDRESS"));
        user.setAge(rs.getInt("AGE"));
        user.setGender(rs.getString("GENDER"));
        user.setID(rs.getString("ID"));
        user.setLoginname(rs.getString("LOGINNAME"));
        user.setPassword(rs.getString("PASSWORD"));
        user.setRepassword(rs.getString("REPASSWORD"));
        user.setTelephone(rs.getString("TELEPHONE"));
        user.setUsername(rs.getString("USERNAME"));
        list.add(user);
      }
      rs.close();
    } catch (Exception e) {
      e.printStackTrace();
    }

    return list;
  }
示例#2
0
 @PUT
 public boolean updateUser(
     @QueryParam("username") String username,
     @QueryParam("password") String password,
     @QueryParam("description") String description) {
   User user = new User();
   user.setUsername(username);
   user.setPassword(password);
   user.setDescription(description);
   return userService.updateUser(user);
 }
 /** 注册 */
 public void signUp() {
   String username = setUsername.getText().toString();
   String password = setPassword.getText().toString();
   String email = setEmail.getText().toString();
   final String displayName = setDisplayname.getText().toString();
   if (TextUtils.isEmpty(username)
       || TextUtils.isEmpty(password)
       || TextUtils.isEmpty(email)
       || TextUtils.isEmpty(displayName)) return;
   showLoadingDialog("正在注册用户...");
   User user = new User();
   user.setUsername(username); // 默认字段有getset方法
   user.setPassword(password);
   user.setEmail(email);
   user.setDisplayName(displayName);
   user.setMobilePhoneNumber(setMobilePhone.getText().toString());
   user.signUpInBackground(
       new SignUpCallback() { // 注册
         @Override
         public void done(AVException e) {
           if (e == null) {
             Utils.showToast(UserActivity.this, "注册成功");
             User user = AVUser.getCurrentUser(User.class); // 注册或登陆后会自动存入用户信息直到注销,否则下回自动登录
             if (user != null) {
               textView.setText(
                   "Username:"******"\n"
                       + "DisplayName:"
                       + user.getDisplayName()
                       + "\n");
             }
           } else { // 根据exception可以判断哪错了
             textView.setText(e.getMessage());
           }
           cancelLoadingDialog();
         }
       });
 }