update
This commit is contained in:
@@ -4,22 +4,35 @@ public class Vote {
|
||||
|
||||
private String[] pays;
|
||||
|
||||
public Vote(String[] args) {
|
||||
public Vote(String[] pays) {
|
||||
this.pays = pays;
|
||||
|
||||
if (pays.length == 0) {
|
||||
System.err.println("Aucun pays compétiteur fourni.");
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
Connection cnx = DriverManager.getConnection("jdbc:mariadb://dwarves.iut-fbleau.fr/srivasta","srivasta", "Tiamzon2006");
|
||||
|
||||
try{
|
||||
PreparedStatement req = cnx.prepareStatement("SELECT Votants, Points FROM tp1_points WHERE Compétiteur = "(?)";");
|
||||
ResultSet rs = req.executeQuery();
|
||||
req.setString(1, this.pays);
|
||||
|
||||
|
||||
while(rs.next()) {
|
||||
System.out.print(rs.getInt(2)+" ");
|
||||
System.out.print(rs.getString(1)+" ");
|
||||
System.out.println(rs.getInt(3));
|
||||
}
|
||||
String query = "SELECT Votants, Points FROM tp1_points WHERE Compétiteur = ?";
|
||||
PreparedStatement req = cnx.prepareStatement(query);
|
||||
req.setString(1, competiteur);
|
||||
|
||||
ResultSet rs = req.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
String votant = rs.getString("Votants");
|
||||
int points = rs.getInt("Points");
|
||||
System.out.printf("%-10s %3d%n", votant, points);
|
||||
total += points;
|
||||
}
|
||||
|
||||
System.out.println(" ---");
|
||||
System.out.printf("Total %3d%n", total);
|
||||
|
||||
try{
|
||||
rs.close();
|
||||
@@ -36,9 +49,4 @@ public class Vote {
|
||||
System.err.println("Erreur de connexion : "+e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Vote vote = new Vote(args);
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user