From 6b8527e3c864453c0142581073f932b0e242fc67 Mon Sep 17 00:00:00 2001 From: HORVILLE Ewen Date: Wed, 7 Sep 2022 11:16:04 +0200 Subject: [PATCH] DEV 3.1 DB --- DEV 3.1/Victoire/RefreshListener.class | Bin 0 -> 377 bytes DEV 3.1/Victoire/RefreshListener.java | 56 ++++++++++++++++++++++++ DEV 3.1/Victoire/Victoire.class | Bin 0 -> 1089 bytes DEV 3.1/Victoire/Victoire.java | 33 ++++++++++++++ DEV 3.1/Vote/Vote.class | Bin 0 -> 2212 bytes DEV 3.1/Vote/Vote.java | 58 +++++++++++++++++++++++++ 6 files changed, 147 insertions(+) create mode 100644 DEV 3.1/Victoire/RefreshListener.class create mode 100644 DEV 3.1/Victoire/RefreshListener.java create mode 100644 DEV 3.1/Victoire/Victoire.class create mode 100644 DEV 3.1/Victoire/Victoire.java create mode 100644 DEV 3.1/Vote/Vote.class create mode 100644 DEV 3.1/Vote/Vote.java diff --git a/DEV 3.1/Victoire/RefreshListener.class b/DEV 3.1/Victoire/RefreshListener.class new file mode 100644 index 0000000000000000000000000000000000000000..3de3218c4e74b075859304952847747aa98b8c6a GIT binary patch literal 377 zcmZvY&rSj{5Ql#Q3&nL2RP<()8+vdr-ZUo0=xL)y4fpOcXbE(aQt-JvX*~D=@rbZL$R>KJQ~lyoUb6M+MTK02`ZNrSAIgO*_}YX4y?Y)z zo maxPoints) { + country = rs.getString(1); + maxPoints = score; + } + } + + rs.close(); + req.close(); + + } catch (SQLException ex) { + System.err.println("SQL Request exception."); + System.err.println (ex); + } + + try { + cnx.close(); + } catch (SQLException ex) { + System.err.println("Unable to close connection."); + } + } + + public void actionPerformed(ActionEvent e) { + Victoire.refresh(); + } +} diff --git a/DEV 3.1/Victoire/Victoire.class b/DEV 3.1/Victoire/Victoire.class new file mode 100644 index 0000000000000000000000000000000000000000..4ef279455799ef41cd20fbaa143e1ca1578bd957 GIT binary patch literal 1089 zcmZuv?M@Rx6g@*fcDpP>7g|0975r-1(xRdwMG=ZsaDga>q?(v)+X0reU9!6c@nw7l zA!&_Gj6aQ!;e#0OY)b@XGkfoyn{(%$duD$A{`w8T3^o*uA}L`~hOVFsDPg9BNeh#a zFfHSb0vRa@cNKIaDK_^c%*ePeAPNG&t@6al3lNP&QS*yp0{e2_kng6|3Im%~F(!i0y6t!*L^#K5p6GT%4Atj%^TpUG?(q^eiX|>qXvpQ>GT%1q6)#t@ zUB0o;9n-VKK*7X{&`=`8ruC6z2_;tiOgCi=yVQY2&2o9MBuY+aW|-)769e-DqLw+2 z@GmDog$&6v(41Y}w`&B?o*~(h+ zh|rFF08HFH*$LW>k!R#XlTEPC6fj&T8*V45h!mw*K!@oU-+wTbU^j8A1N)93^#HsU zx(ZsLiJ+l}8wlx9mZH@_SdZcdtp=nPA?n~EocR; zpAH!~LCoL8+nYiC7%^=~;Epk<4O8$1BYy{&!zJR-3k7{-qeNb#!3Hpe7-kX20tT^6 Z*;g3Bds1qLl-MVQT+)W&Hq~|^@dsSb=coVx literal 0 HcmV?d00001 diff --git a/DEV 3.1/Victoire/Victoire.java b/DEV 3.1/Victoire/Victoire.java new file mode 100644 index 0000000..c95cff4 --- /dev/null +++ b/DEV 3.1/Victoire/Victoire.java @@ -0,0 +1,33 @@ +import java.sql.*; +import javax.swing.*; +import java.awt.*; + +public class Victoire { + + public static JLabel scoreLabel; + public static JLabel countryLabel; + + public static void refresh() { + + } + + public static void main(String[] args) { + JFrame window = new JFrame("Victoire"); + window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + window.setSize(300, 300); + window.setLocation(200, 200); + + JButton refreshBT = new JButton("⟳"); + refreshBT.addActionListener(new RefreshListener()); + window.add(refreshBT, BorderLayout.SOUTH); + window.setVisible(true); + + countryLabel = new JLabel("...", JLabel.CENTER); + scoreLabel = new JLabel("0", JLabel.CENTER); + + window.add(countryLabel, BorderLayout.NORTH); + window.add(scoreLabel, BorderLayout.CENTER); + + Victoire.refresh(); + } +} \ No newline at end of file diff --git a/DEV 3.1/Vote/Vote.class b/DEV 3.1/Vote/Vote.class new file mode 100644 index 0000000000000000000000000000000000000000..8534ac61b8c124d2b285d33cc03edb1d958373a6 GIT binary patch literal 2212 zcmZ`)OLG%P5dKD5Ygh6bfsAZyUTa>ljV&310oz~_zk(CV*p`jMD`6###Tsc>-iNV6 z-tS+Ks+>~Ag{s`(U~p2!B{xn~CCA)yN>y@9s!~Zode#q#py)6&>goQv`|F3*A$#rFkX+>@kTvT zNQ-4cEEnoAi7By6izOpKXJpJqunVWea#6vY*xwY(B?XriToIaAh4obh*M$4G1Ty`3 zTgG)6Iz#A;VH)lrL$JN$B7-z+z}8p1YaW%f3D(N4dzz%E-yc%OHeE#`5eOA2S48_@d?Vgg{c!jt&{~ zDhjy4uw%l~a+YVh_KH?8mbjUaVW?QZO@?O6E+k62ZRq)IVj-W+B}Qygv1JrhltAHW zmDq-hy5me(?ihjPN0)QF>>3uS>`DuOks&Sb+iIreYV$&ep<7_~Z#d{rCiAy+dx<*< z!*jdmi3QzD%-hKumc3*YMG{Ko7}9$SxxQW*mWnbK8RC8<&SEi{nMzf;Z=E#-p_*%H zdM?KuM;p;yJ*zuB!O)i(O^puEXhe=~x=xoiX&JO@W78MXLddnb^P|(F+OSnBbJuXW zXKQD*_H!KrM70VV4)LwRg{NW(w^S@+h3HrD4sNS>7w@TfA0MdrP%zzG;cC5(L!MF0 zb6dqn_?RJ}Y2x&Wicj$wb%a*+>+bHRiqBA##Z9S-&(T5sLD_24e9_~MtMN_N6QY1$ zFzl`*pDS7pr%Ib9&xyiN_L9huVS6R63)uy_WoXup><0-Y4fsf^E~yS%S+rO zli1efG8#RyVBVB=xyVEOEUwuo=$tVg|V^l#0}1 z@%GwpBwESL?@qFrx9kbML|GrMWm5&?8<6j&t-RKIKdqa3fm5&z1@2a}ldb_+g}3o^ zUzBvLi$v#E;K=dz@;b>?9QV|4QDy!@RR|^QaKR%@4KYi`Yq%G)gfH`)=knQdp6cn3 zrf~*!LptSgdqr4Rx!S5RxsXi0Otq$YcA5MUE1Uk}?c*CJ)x(QMAnA;Yo{>m_90e_p z{)F^$nfp`W|Ff*Z*?2tUe@`tpm21VdHUrwZnL-r~0o3_#<3DY*{uF4`q76srqauC* zFflx7?WBKuX=k+8bv^*QM+b(Zw1#|P5Mgwoo6e-l{(=OV?*8n2B;A2}AAwkK71F&} z-9v=t?xGus=`N`=czg{zg6LX9jA1S~NQXv- zeyK%T!%l{;G1wx}F&;pFU5iw=hNb{chW5ro*9Y&T`FrfT^Z+d_b*pHN?WQFjTE(7K z>?JpMpFJXt*giT|G-LZoiEcM^gcpqo?`;fs(dfr`z_$o=t>WO(H5?Kbs(*1<1W(yV z5vQ-Dj040<5)J6X6Z}Z~FZdO|(H`)*`wE8zp~PVb+ekZ#da{d>rHU5PY9r|ZG!jNL zq3lEt-JV7hp|xTNyXm{T2N~?cEcW9XH2T7|VUa9u;}Ff@Blw02d4~%4Emh?QLU~LT zdV=E=NfJL1+Rr#f5%p3`rzxtF_#LP42cah@s$SGb&&x=LQ!;w~L0HDIr#L9%IFs@6 b-xzsD_5m3uNDdP92<0Ay8labqsQ~{1RG2I7 literal 0 HcmV?d00001 diff --git a/DEV 3.1/Vote/Vote.java b/DEV 3.1/Vote/Vote.java new file mode 100644 index 0000000..11cade7 --- /dev/null +++ b/DEV 3.1/Vote/Vote.java @@ -0,0 +1,58 @@ +import java.sql.*; + +public class Vote { + public static void main(String[] args) { + if (args.length < 1) { + System.err.println("No country given."); + return; + } + + try { + Class.forName("org.mariadb.jdbc.Driver"); + } catch (ClassNotFoundException ex) { + System.err.println("MariaDB driver not found"); + return; + } + + Connection cnx; + try { + cnx = DriverManager.getConnection("jdbc:mariadb://dwarves.iut-fbleau.fr/horville", "horville", "a5gc95"); + } catch (SQLException ex) { + System.err.println("Unable to access Database."); + return; + } + + try { + PreparedStatement req = cnx.prepareStatement("SELECT Votants, Points FROM Vote WHERE Competiteur = (?);"); + req.setString(1, args[0]); + req.executeUpdate(); + + int total = 0; + ResultSet rs = req.executeQuery(); + while (rs.next()) { + String country = rs.getString(1); + int score = rs.getInt(2); + + total += score; + + System.out.println(country + " " + score); + } + + System.out.println(" ---"); + System.out.println("Total " + total); + + rs.close(); + req.close(); + + } catch (SQLException ex) { + System.err.println("SQL Request exception."); + System.err.println (ex); + } + + try { + cnx.close(); + } catch (SQLException ex) { + System.err.println("Unable to close connection."); + } + } +} \ No newline at end of file