public boolean delete(Team team) { try { this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY) .executeUpdate("DELETE FROM teams WHERE te_id = " + team.getID()); } catch (SQLException e) { e.printStackTrace(); return false; } return true; }
public boolean create(Team team) { try { this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY) .executeUpdate( "INSERT INTO teams VALUES (" + team.getID() + "," + team.getPoints() + ")"); } catch (SQLException e) { e.printStackTrace(); return false; } return true; }
public ArrayList<Player> getPlayerList(Team team) { ArrayList<Player> players = new ArrayList<>(); try { Statement state = this.connect.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); ResultSet result = state.executeQuery("SELECT pl_id FROM players WHERE te_id =" + team.getID()); PlayerDAO playerDAO = (PlayerDAO) DAOFactory.getPlayerDAO(); while (result.next()) { players.add(playerDAO.find(result.getInt(1))); } } catch (SQLException e) { e.printStackTrace(); } return players; }