/*
* should create the league in DB at the start of the season
*
* UNDER DEVELOPMENT
*/
public void createLeagus()
{
String sqlSelect= "SELECT team_num, place " +
"FROM clubs_information " +
"WHERE current_league = 1 " +
"ORDER BY place";
String sqlInsert= "INSERT INTO seasons_tables " +
"(year, team_num, round, w_group, wins, losts, draw, positive, negative, points) VALUES " +
"("+Season.getYear()+", ?, 1, ?, 0, 0, 0, 0, 0, 0)";
System.out.println(sqlInsert);
try
{
resultSet=statement.executeQuery(sqlSelect);
PreparedStatement preparedStatement=connection.prepareStatement(sqlInsert);
while(resultSet.next())
{
int place=resultSet.getInt("place");
int group=0;
int teamNum=resultSet.getInt("team_num");
if(place%10 == 1 || place%10 == 0)
group=1;
if(place%10 == 2 || place%10 == 9)
group=2;
if(place%10 == 3 || place%10 == 8)
group=3;
if(place%10 == 4 || place%10 == 7)
group=4;
if(place%10 == 5 || place%10 == 6)
group=5;
preparedStatement.setInt(1, teamNum);
preparedStatement.setInt(2, group);
preparedStatement.addBatch();
System.out.println("INSERT NUM: " + teamNum + "TO GROUP : " + group );
}
preparedStatement.executeBatch();
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
}