Files
DEV/DEV.3.1/TP/TP1/Vote.java
EmmanuelTiamzon 9e770734ac update
2025-09-16 12:27:47 +02:00

43 lines
942 B
Java

import java.sql.*;
public class Vote {
private String[] pays;
public Vote(String[] args) {
this.pays = pays;
try{
Connection cnx = DriverManager.getConnection("jdbc:mariadb://dwarves.iut-fbleau.fr/srivasta","srivasta", "Tiamzon2006");
try{
PreparedStatement req = cnx.prepareStatement("SELECT * FROM tp1_points;");
ResultSet rs = req.executeQuery();
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);
}
} catch(SQLException e) {
System.err.println("Erreur de connexion : "+e);
}
}
public static void main(String[] args) {
Vote vote = new Vote(args);
}
}