javais zapper beaucoup de truc...
This commit is contained in:
BIN
DEV3.1/BDD_java/vote.class
Normal file
BIN
DEV3.1/BDD_java/vote.class
Normal file
Binary file not shown.
55
DEV3.1/BDD_java/vote.java
Normal file
55
DEV3.1/BDD_java/vote.java
Normal file
@@ -0,0 +1,55 @@
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
|
||||
public class vote
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
Connection cnx = DriverManager.getConnection("jdbc:mariadb://dwarves.iut-fbleau.fr/sayebabu","sayebabu", "kjrzB5S4kqKAwdT");
|
||||
try
|
||||
{
|
||||
PreparedStatement pst = cnx.prepareStatement("SELECT PaysID FROM `Pays` WHERE Pays = '?'");
|
||||
pst.setString(1, args[0]);
|
||||
ResultSet rs = pst.executeQuery();
|
||||
int paysID = rs.getInt(1);
|
||||
pst = cnx.prepareStatement("SELECT PaysVoteID, Points FROM `Comp` WHERE PaysCompID = '?'");
|
||||
pst.setInt(1, paysID);
|
||||
|
||||
int sumVote = 0;
|
||||
while(rs.next())
|
||||
{
|
||||
int comp = rs.getInt(1);
|
||||
int votants = rs.getInt(2);
|
||||
sumVote+=votants;
|
||||
|
||||
PreparedStatement pst2 = cnx.prepareStatement("SELECT Pays FROM `Pays` WHERE PaysID = '?'");
|
||||
pst2.setInt(1, comp);
|
||||
ResultSet rs2 = pst.executeQuery();
|
||||
rs2.next();
|
||||
String PaysName = rs2.getString(1);
|
||||
|
||||
|
||||
System.out.printf("%20s,%f \n",PaysName,votants);
|
||||
}
|
||||
System.out.printf("%20s --- \n", " ");
|
||||
System.out.printf("%20s %f \n", "Total",sumVote);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
cnx.close();
|
||||
System.out.printf("TA MERE");
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.printf("TA MERE");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user