fini ex 1 du transition

This commit is contained in:
2024-09-12 15:19:28 +02:00
parent 0f828b31cf
commit 6e4a3d85d0
29 changed files with 876 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,47 @@
import java.sql.*;
public class Vote{
public static void main (String[] arg){
try{
Class.forName("org.mariadb.jdbc.Driver");
}catch(ClassNotFoundException e){
System.err.println("pas de disponibilité");
System.exit(1);
}
try{
Connection bd = DriverManager.getConnection(
"jdbc:mariadb://dwarves.iut-fbleau.fr/felix-vi",
"felix-vi", "felix-vi");
try{
PreparedStatement pst = bd.prepareStatement(
"SELECT votants, points FROM Vote WHERE competiteur = ?");
pst.setString(1, arg[0]);
ResultSet rs = pst.executeQuery();
try{
int total = 0;
while(rs.next()) {
total += rs.getInt(2);
System.out.print(rs.getString(1));
System.out.print(" ");
System.out.println(rs.getInt(2));
}
System.out.print("Total ");
System.out.println(total);
rs.close();
}catch(SQLException e){
System.err.println("mal affichage");
System.exit(1);
}
pst.close();
}catch(SQLException e){
System.err.println("mal execute");
System.exit(1);
}
bd.close();
}catch(SQLException e){
System.err.println("mauvais mdp");
System.exit(1);
}
}
}