예제 #1
0
  public boolean valid(String email, String password) throws SQLException {
    String sql = "select * from user where email = ?";

    User result = queryRunner.query(sql, userBeanHandler, email);
    if (result != null && result.getPassword().equals(password)) {
      return true;
    } else {
      return false;
    }
  }
예제 #2
0
 public void insertOrUpdate(User user) throws SQLException {
   String sql = "";
   if (select(user.getId()) != null) {
     sql = "update user set name=?, email=?,password=?,gender=?,role=?,age=? where id = ?";
     queryRunner.update(
         sql,
         user.getIdNumber(),
         user.getUserName(),
         user.getEmail(),
         user.getPassword(),
         user.getGender(),
         user.getRole(),
         user.getAge(),
         user.getId());
   } else {
     sql = "insert into user(idNumber,name,email,password,gender,role,age) values(?,?,?,?,?,?,?)";
     queryRunner.update(
         sql,
         user.getIdNumber(),
         user.getUserName(),
         user.getEmail(),
         user.getPassword(),
         user.getGender(),
         user.getRole(),
         user.getAge());
   }
   System.out.println("Insert Or Update:" + sql);
 }