示例#1
0
  @Override
  public void insertRegistry(UserAccount account) throws java.sql.SQLException {
    String query =
        "INSERT INTO user VALUES "
            + "(NULL,'"
            + account.getName()
            + "','"
            + account.getLogin()
            + "','"
            + account.getPassword()
            + "','"
            + account.getEmail()
            + "');";

    MySql.stm.executeUpdate(query);
  }
示例#2
0
  @Override
  public void alterRegistry(UserAccount account) throws java.sql.SQLException {

    String query =
        "UPDATE user SET name =\" "
            + account.getName()
            + "\",login = \""
            + account.getLogin()
            + "\",password =\""
            + account.getPassword()
            + "\", email = \""
            + account.getEmail()
            + "\"WHERE iduser = "******";";

    MySql.stm.executeUpdate(query);
  }
示例#3
0
  @Override
  public UserAccount selectRegistry(int iduser) throws SQLException {
    String query = "SELECT * FROM user WHERE iduser ="******";";

    MySql.rs = MySql.stm.executeQuery(query);
    MySql.stm = MySql.conn.createStatement();

    if (MySql.rs.next()) {
      UserAccount userData = new UserAccount();
      userData.setIdUser(Integer.parseInt(MySql.rs.getString("iduser")));
      userData.setName(MySql.rs.getString("name"));
      userData.setLogin(MySql.rs.getString("login"));
      userData.setPassword(MySql.rs.getString("password"));
      userData.setEmail(MySql.rs.getString("email"));
      return userData;
    } else {
      throw new SQLException();
    }
  }
示例#4
0
 @Override
 public void deleteRegistry(UserAccount account) throws java.sql.SQLException {
   String query = "DELETE FROM user WHERE iduser = "******";";
   MySql.stm.executeUpdate(query);
 }