septembre + octobre
2
DEV/DEV3.1/TP01_BD/.bashrc
Normal file
@@ -0,0 +1,2 @@
|
||||
alias javacdb='javac -cp ".:/export/documents/mariadb-client.jar"'
|
||||
alias javadb='java -cp ".:/export/documents/mariadb-client.jar"'
|
1
DEV/DEV3.1/TP01_BD/.bashrc~
Normal file
@@ -0,0 +1 @@
|
||||
alias javacdb='java -cp ".:/export/documents/mariadb-client.jar"'
|
BIN
DEV/DEV3.1/TP01_BD/Q1Main.class
Normal file
116
DEV/DEV3.1/TP01_BD/Q1Main.java
Normal file
@@ -0,0 +1,116 @@
|
||||
import org.mariadb.jdbc.*;
|
||||
import java.sql.*;
|
||||
|
||||
public class Q1Main{
|
||||
public static void main(String[] args) {
|
||||
if (args.length < 1){
|
||||
System.out.println("Arguments invalide");
|
||||
System.exit(0);
|
||||
}
|
||||
String pays = args[0];
|
||||
try{
|
||||
int idPays = -1;
|
||||
Connection cnx = DriverManager.getConnection(
|
||||
"jdbc:mariadb://dwarves.iut-fbleau.fr/wamster",
|
||||
"wamster","32201909");
|
||||
try {
|
||||
Class.forName("org.mariadb.jdbc.Driver");
|
||||
}
|
||||
catch(ClassNotFoundException e){
|
||||
System.out.println("ClassNotFoundException");
|
||||
cnx.close();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
|
||||
// recuperation de l'id du pays entree en ligne de commande
|
||||
try {
|
||||
PreparedStatement pst = cnx.prepareStatement(
|
||||
"SELECT idPays FROM DEV31TP01Q1_ListePays WHERE nomPays=?");
|
||||
pst.setString(1, pays);
|
||||
ResultSet rs = pst.executeQuery();
|
||||
pst.close();
|
||||
if (rs.next()){
|
||||
idPays = rs.getInt("idPays");
|
||||
}
|
||||
rs.close();
|
||||
if (idPays == -1){
|
||||
System.out.println("Pays inconnus");
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
catch(SQLException e){
|
||||
System.out.println("probleme de select 1");
|
||||
cnx.close();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
// recuperation des score du pays
|
||||
try {
|
||||
PreparedStatement pst = cnx.prepareStatement(
|
||||
"SELECT * FROM DEV31TP01Q1_score WHERE idCompetiteurs=?");
|
||||
pst.setInt(1, idPays);
|
||||
ResultSet rsid = pst.executeQuery();
|
||||
pst.close();
|
||||
int scoreTotal = 0;
|
||||
|
||||
//recuperation du nom du votant à partir de son id
|
||||
try{
|
||||
pst = cnx.prepareStatement(
|
||||
"SELECT nomPays FROM DEV31TP01Q1_ListePays WHERE idPays=?");
|
||||
while (rsid.next()){
|
||||
int idVotant = rsid.getInt("idVotants");
|
||||
int score = rsid.getInt("score");
|
||||
String nomVotant = null;
|
||||
pst.setInt(1, idVotant);
|
||||
ResultSet rsnom = pst.executeQuery();
|
||||
if (rsnom.next()){
|
||||
nomVotant = rsnom.getString("NomPays");
|
||||
}
|
||||
rsnom.close();
|
||||
|
||||
// affichage du score qu'a donne le votant (aligner proprement)
|
||||
System.out.print(nomVotant);
|
||||
int espaceAAjouter = 20 - (nomVotant.length() + Integer.toString(score).length());
|
||||
for (int i=0; i<espaceAAjouter; i++){
|
||||
System.out.print(" ");
|
||||
}
|
||||
System.out.println(score);
|
||||
scoreTotal += score;
|
||||
}
|
||||
pst.close();
|
||||
rsid.close();
|
||||
|
||||
//affichage du score total
|
||||
for (int i=0; i<17; i++){
|
||||
System.out.print(" ");
|
||||
}
|
||||
System.out.println("___");
|
||||
int espaceAAjouter = 20 - ("Total".length() + Integer.toString(scoreTotal).length());
|
||||
System.out.print("Total");
|
||||
for (int i=0; i<espaceAAjouter; i++){
|
||||
System.out.print(" ");
|
||||
}
|
||||
System.out.println(scoreTotal);
|
||||
|
||||
}
|
||||
catch(SQLException e){
|
||||
System.out.println("probleme de select ?");
|
||||
cnx.close();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
}
|
||||
catch(SQLException e){
|
||||
System.out.println("probleme de select 2");
|
||||
cnx.close();
|
||||
System.exit(0);
|
||||
}
|
||||
cnx.close();
|
||||
|
||||
}
|
||||
catch(SQLException e){
|
||||
System.out.println("SQLException");
|
||||
}
|
||||
}
|
||||
}
|
65
DEV/DEV3.1/TP01_BD/Q1Main.java~
Normal file
@@ -0,0 +1,65 @@
|
||||
import org.mariadb.jdbc.*;
|
||||
import java.sql.*;
|
||||
|
||||
public class Q1Main{
|
||||
public static void main(String[] args) {
|
||||
if (args.length < 1){
|
||||
System.out.println("Arguments invalide");
|
||||
System.exit(0);
|
||||
}
|
||||
String pays = args[0];
|
||||
try{
|
||||
Connection cnx = DriverManager.getConnection(
|
||||
"jdbc:mariadb://dwarves.iut-fbleau.fr/wamster",
|
||||
"wamster","32201909");
|
||||
try {
|
||||
Class.forName("org.mariadb.jdbc.Driver");
|
||||
}
|
||||
catch(ClassNotFoundException e){
|
||||
System.out.println("ClassNotFoundException");
|
||||
cnx.close();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
|
||||
// récupération de l'id du pays entrée en ligne de commande
|
||||
try {
|
||||
PreparedStatement pst = cnx.prepareStatement(
|
||||
"SELECT idPays FROM DEV31TP01Q1_ListePays WHERE nomPays=?");
|
||||
pst.setString(1, pays);
|
||||
ResultSet rs = pst.executeQuery();
|
||||
pst.close();
|
||||
int idPays = -1;
|
||||
if (rs.next()){
|
||||
idPays = rs.getInt("idPays");
|
||||
}
|
||||
rs.close();
|
||||
if (idPays == -1){
|
||||
System.out.println("Pays inconnus");
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
catch(SQLException e){
|
||||
System.out.println("problème de select 1");
|
||||
cnx.close();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
// récupération des score du pays
|
||||
PreparedStatement pst = cnx.prepareStatement(
|
||||
"SELECT * FROM DEV31TP01Q1_score WHERE idCompetiteurs=?");
|
||||
pst.setInt(1, idPays);
|
||||
ResultSet rs = pst.executeQuery();
|
||||
while (rs.next()){
|
||||
System.out.println(rs.getInt("idCompetiteurs")+" "+rs.getInt("idVotants")+" "+rs.getInt("score"));
|
||||
}
|
||||
rs.close();
|
||||
pst.close();
|
||||
cnx.close();
|
||||
|
||||
}
|
||||
catch(SQLException e){
|
||||
System.out.println("SQLException");
|
||||
}
|
||||
}
|
||||
}
|
BIN
DEV/DEV3.1/TP01_BD/Q2BestPays.class
Normal file
64
DEV/DEV3.1/TP01_BD/Q2BestPays.java
Normal file
@@ -0,0 +1,64 @@
|
||||
import org.mariadb.jdbc.*;
|
||||
import java.sql.*;
|
||||
|
||||
public class Q2BestPays{
|
||||
public static String[] bestPays() {
|
||||
try{
|
||||
int idPays = -1;
|
||||
String nomPays = null;
|
||||
String bestPays = null;
|
||||
int score = 0;
|
||||
int bestScore = 0;
|
||||
|
||||
Connection cnx = DriverManager.getConnection(
|
||||
"jdbc:mariadb://dwarves.iut-fbleau.fr/wamster",
|
||||
"wamster","32201909");
|
||||
try {
|
||||
Class.forName("org.mariadb.jdbc.Driver");
|
||||
}
|
||||
catch(ClassNotFoundException e){
|
||||
cnx.close();
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
PreparedStatement pstCompetiteur = cnx.prepareStatement(
|
||||
"SELECT * FROM DEV31TP01Q1_ListePays");
|
||||
ResultSet rsCompetiteur = pstCompetiteur.executeQuery();
|
||||
while (rsCompetiteur.next()){
|
||||
idPays = rsCompetiteur.getInt("idPays");
|
||||
nomPays = rsCompetiteur.getString("NomPays");
|
||||
score = 0;
|
||||
PreparedStatement pstScore = cnx.prepareStatement(
|
||||
"SELECT score FROM DEV31TP01Q1_score WHERE idCompetiteurs=?");
|
||||
pstScore.setInt(1, idPays);
|
||||
ResultSet rsScore = pstScore.executeQuery();
|
||||
pstScore.close();
|
||||
while (rsScore.next()){
|
||||
score += rsScore.getInt("score");
|
||||
}
|
||||
rsScore.close();
|
||||
if (score > bestScore){
|
||||
bestScore = score;
|
||||
bestPays = nomPays;
|
||||
}
|
||||
}
|
||||
rsCompetiteur.close();
|
||||
pstCompetiteur.close();
|
||||
if (idPays == -1){
|
||||
cnx.close();
|
||||
return null;
|
||||
}
|
||||
cnx.close();
|
||||
return new String[] {bestPays, Integer.toString(bestScore)};
|
||||
}
|
||||
catch(SQLException e){
|
||||
cnx.close();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch(SQLException e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
BIN
DEV/DEV3.1/TP01_BD/Q2Evenement.class
Normal file
22
DEV/DEV3.1/TP01_BD/Q2Evenement.java
Normal file
@@ -0,0 +1,22 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Q2Evenement implements ActionListener{
|
||||
public JLabel pays;
|
||||
public JLabel score;
|
||||
|
||||
public Q2Evenement(JLabel pays, JLabel score){
|
||||
this.pays = pays;
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent evenement){
|
||||
String[] bestPays = Q2BestPays.bestPays();
|
||||
if (bestPays != null){
|
||||
this.pays.setText(bestPays[0]);
|
||||
this.score.setText(bestPays[1]);
|
||||
}
|
||||
}
|
||||
}
|
BIN
DEV/DEV3.1/TP01_BD/Q2Main.class
Normal file
35
DEV/DEV3.1/TP01_BD/Q2Main.java
Normal file
@@ -0,0 +1,35 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Q2Main{
|
||||
public static void main(String[] args) {
|
||||
|
||||
JFrame fenetre = new JFrame("Question 2");
|
||||
fenetre.setSize(300, 200);
|
||||
fenetre.setLocation(700, 300);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
JLabel labelPays = new JLabel("", JLabel.CENTER);
|
||||
JLabel labelScore = new JLabel("", JLabel.CENTER);
|
||||
|
||||
JButton bouton = new JButton("o");
|
||||
JPanel bas = new JPanel(new BorderLayout());
|
||||
bas.add(bouton,BorderLayout.EAST);
|
||||
|
||||
String[] bestPays = Q2BestPays.bestPays();
|
||||
if (bestPays != null){
|
||||
labelPays.setText(bestPays[0]);
|
||||
labelScore.setText(bestPays[1]);
|
||||
}
|
||||
|
||||
fenetre.add(labelPays, BorderLayout.NORTH);
|
||||
fenetre.add(labelScore, BorderLayout.CENTER);
|
||||
fenetre.add(bas, BorderLayout.SOUTH);
|
||||
|
||||
Q2Evenement evenementBouton = new Q2Evenement(labelPays, labelScore);
|
||||
bouton.addActionListener(evenementBouton);
|
||||
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
56
DEV/DEV3.1/TP01_BD/Question1.java~
Normal file
@@ -0,0 +1,56 @@
|
||||
import org.mariadb.jdbc.*;
|
||||
|
||||
public class Q1Main{
|
||||
public static void main(String[] args) {
|
||||
if (args.length < 1){
|
||||
System.out.println("Arguments invalide");
|
||||
return 0;
|
||||
}
|
||||
String pays = args[0];
|
||||
try{
|
||||
Connection cnx = DriverManager.getConnection(
|
||||
"jdbc:mariadb://dwarves.iut-fbleau.fr/wamster",
|
||||
"wamster","...");
|
||||
try {
|
||||
Class.forName("org.mariadb.jdbc.Driver");
|
||||
}
|
||||
catch(ClassNotFoundException){
|
||||
System.out.println("ClassNotFoundException");
|
||||
cnx.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// récupération de l'id du pays entrée en ligne de commande
|
||||
PreparedStatement pst = cnx.prepareStatement(
|
||||
"SELECT idPays FROM DEV31TP01Q1_ListePays WHERE nomPays=?");
|
||||
pst.setString(1, pays);
|
||||
ResultSet rs = pst.executeQuery();
|
||||
pst.close();
|
||||
int idPays = null;
|
||||
if (rs.next()){
|
||||
idPays = rs;
|
||||
}
|
||||
rs.close();
|
||||
if (idPays == null){
|
||||
System.out.println("Pays inconnus");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// récupération des score du pays
|
||||
PreparedStatement pst = cnx.prepareStatement(
|
||||
"SELECT * FROM DEV31TP01Q1_score WHERE idCompetiteurs=?");
|
||||
pst.setInt(1, idPays);
|
||||
ResultSet rs = pst.executeQuery();
|
||||
while (rs.next()){
|
||||
System.out.println(rs);
|
||||
}
|
||||
rs.close();
|
||||
pst.close();
|
||||
|
||||
}
|
||||
catch(SQLException){
|
||||
System.out.println("SQLException");
|
||||
cnx.close();
|
||||
}
|
||||
}
|
||||
}
|
0
DEV/DEV3.1/TP02_Transitions/Image.java~
Normal file
BIN
DEV/DEV3.1/TP02_Transitions/Images/0000000.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0000100.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0000200.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0000300.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0000400.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0000500.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0000600.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0000700.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0000800.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0000900.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0001000.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0001100.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0001200.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0001300.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0001400.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0001500.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0001600.png
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0001700.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0001800.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0001900.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0002000.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0002100.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0002200.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0002300.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0002400.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0002500.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0002600.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0002700.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0002800.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0002900.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0003000.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0003100.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0003200.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0003300.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0003400.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0003500.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
DEV/DEV3.1/TP02_Transitions/Images/0003600.png
Normal file
After Width: | Height: | Size: 26 KiB |