Files
DEV/DEV.3.1/TP/TP1/Vote.java

44 lines
1016 B
Java
Raw Normal View History

2025-09-05 19:30:04 +02:00
import java.sql.*;
public class Vote {
2025-09-16 10:27:52 +02:00
private String[] pays;
2025-09-05 19:45:08 +02:00
2025-09-16 10:27:52 +02:00
public Vote(String[] args) {
2025-09-05 19:30:04 +02:00
this.pays = pays;
2025-09-05 19:45:08 +02:00
try{
Connection cnx = DriverManager.getConnection("jdbc:mariadb://dwarves.iut-fbleau.fr/srivasta","srivasta", "Tiamzon2006");
2025-09-16 12:27:47 +02:00
try{
2025-09-16 12:30:12 +02:00
PreparedStatement req = cnx.prepareStatement("SELECT Votants, Points FROM tp1_points WHERE Compétiteur = "(?)";");
2025-09-16 12:27:47 +02:00
ResultSet rs = req.executeQuery();
2025-09-16 12:30:12 +02:00
req.setString(1, this.pays);
2025-09-16 12:27:47 +02:00
while(rs.next()) {
System.out.print(rs.getInt(2)+" ");
System.out.print(rs.getString(1)+" ");
System.out.println(rs.getInt(3));
}
try{
rs.close();
req.close();
cnx.close();
}catch(SQLException e) {
System.err.println("Erreur de connexion : "+e);
}
}catch(SQLException e) {
System.err.println("Erreur SQL ou de connexion : "+e);
}
2025-09-05 19:45:08 +02:00
} catch(SQLException e) {
System.err.println("Erreur de connexion : "+e);
}
2025-09-05 19:30:04 +02:00
}
2025-09-16 10:27:52 +02:00
public static void main(String[] args) {
2025-09-16 12:27:47 +02:00
Vote vote = new Vote(args);
2025-09-16 10:27:52 +02:00
}
2025-09-05 19:30:04 +02:00
}