DEV TP01
This commit is contained in:
@@ -1,26 +1,16 @@
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Database database = new Database();
|
||||
|
||||
String country = "France";
|
||||
ResultSet result = database.getVotesFromCompetitor(country);
|
||||
Votes votesForItaly = database.getVotesFromCompetitor("Italie");
|
||||
|
||||
try {
|
||||
while(result.next()) {
|
||||
System.out.println(country + " -> " + result.getString("name") + " : " + result.getInt("points"));
|
||||
}
|
||||
} catch(SQLException exception) {
|
||||
System.err.println("Error while read the data from the result.");
|
||||
System.out.println("Vote " + votesForItaly.getCompetitorName() + " :");
|
||||
for(Vote vote : votesForItaly.getVoters()) {
|
||||
System.out.println(vote.getVoterName() + " " + vote.getPoints());
|
||||
}
|
||||
|
||||
try {
|
||||
result.close();
|
||||
} catch(SQLException exception) {
|
||||
System.err.println("Error while trying to close the result.");
|
||||
}
|
||||
System.out.println("-------------------");
|
||||
System.out.println("Total " + votesForItaly.getTotalPoints());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user