44 lines
1016 B
Java
44 lines
1016 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 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));
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
} |