Example #1
0
  public PlayerSkills getPlayerSkills(Player player, Training training) throws SQLException {
    PreparedStatement ps =
        connection.prepareStatement(
            "select * from player_skills where ((day >= 5 and week = ?) or (day < 5 and week = ?)) and id_player_fk = ?");
    // SokkerDate sokkerDate = null;
    PlayerSkills playerSkills = null;
    int week = training.getDate().getSokkerDate().getWeek();
    int day = training.getDate().getSokkerDate().getDay();
    if (day >= SokkerDate.THURSDAY) {
      ps.setInt(1, week);
      ps.setInt(2, week + 1);

    } else {
      ps.setInt(1, week - 1);
      ps.setInt(2, week);
    }
    ps.setInt(3, player.getId());
    ResultSet rs = ps.executeQuery();
    if (rs.next()) {
      // sokkerDate = new SokkerDate(rs.getInt("day"), rs.getInt("week"));
      playerSkills = new PlayerSkillsDto(rs).getPlayerSkills();
    }

    rs.close();
    ps.close();

    return playerSkills;
  }
Example #2
0
  public void updatePlayerSkills(int id, PlayerSkills skills, Training training)
      throws SQLException {
    PreparedStatement ps =
        connection.prepareStatement(
            "UPDATE player_skills SET millis = ?, age = ?, value = ?, salary = ?, form = ?, "
                + "stamina = ?, pace = ?, technique = ?, passing = ?, keeper = ?, defender = ? ,playmaker = ?, scorer = ?, matches = ?, goals = ?, "
                + "assists = ?, "
                + "cards = ?, "
                + "injurydays = ?, day = ?, week = ?, experience = ?, teamwork = ?, discipline = ?, weight = ?, bmi = ? "
                + "WHERE id_player_fk = ? AND id_training_fk = ?");

    ps.setLong(1, training.getDate().getMillis());
    ps.setInt(2, skills.getAge());
    ps.setInt(3, skills.getValue().toInt());
    ps.setInt(4, skills.getSalary().toInt());
    ps.setInt(5, skills.getForm());
    ps.setInt(6, skills.getStamina());
    ps.setInt(7, skills.getPace());
    ps.setInt(8, skills.getTechnique());
    ps.setInt(9, skills.getPassing());
    ps.setInt(10, skills.getKeeper());
    ps.setInt(11, skills.getDefender());
    ps.setInt(12, skills.getPlaymaker());
    ps.setInt(13, skills.getScorer());
    ps.setInt(14, skills.getMatches());
    ps.setInt(15, skills.getGoals());
    ps.setInt(16, skills.getAssists());
    ps.setInt(17, skills.getCards());
    ps.setDouble(18, skills.getInjurydays());
    ps.setInt(19, training.getDate().getSokkerDate().getDay());
    ps.setInt(20, training.getDate().getSokkerDate().getWeek());
    ps.setInt(21, skills.getExperience());
    ps.setInt(22, skills.getTeamwork());
    ps.setInt(23, skills.getDiscipline());
    ps.setDouble(24, skills.getWeight());
    ps.setDouble(25, skills.getBmi());
    ps.setInt(26, id);
    ps.setInt(27, training.getId());

    ps.executeUpdate();
    ps.close();
  }