package fr.iutfbleau.projetIHM2022FI2.Graphic; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.LinkedList; import java.util.Objects; import java.sql.Connection; import org.mariadb.jdbc.*; import java.sql.DriverManager; import java.sql.ResultSet; import javax.swing.JFrame; import javax.swing.*; import java.awt.*; import fr.iutfbleau.projetIHM2022FI2.API.AbstractGroupeFactory; import fr.iutfbleau.projetIHM2022FI2.API.Groupe; import fr.iutfbleau.projetIHM2022FI2.API.TypeGroupe; import fr.iutfbleau.projetIHM2022FI2.Graphic.View.PaintGroupe; import fr.iutfbleau.projetIHM2022FI2.MNP.AbstractGroupeFactoryNP; import fr.iutfbleau.projetIHM2022FI2.MNP.GroupeNP; public class Graphic{ private PaintGroupe paint; private JFrame fenetre; private AbstractGroupeFactory agf; public Graphic(){ this.fenetre=new JFrame("Gestion des étudiants"); this.fenetre.setSize(1000, 720); this.fenetre.setLocation(200,200); this.fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); agf=this.getPromo(); this.fenetre.setVisible(true); } private AbstractGroupeFactory getPromo(){ try{ Class.forName("org.mariadb.jdbc.Driver"); try{ Connection cnx = DriverManager.getConnection( "jdbc:mariadb://dwarves.iut-fbleau.fr/chaignea", "chaignea", "Chaigneauphpmyadmin"); try{ PreparedStatement pst = cnx.prepareStatement( "SELECT `id`, `nom`, `min`, `max`, `value`, `id-parent` FROM `Groupe` join `TYPE` on Groupe.Type=TYPE.name ORDER BY Groupe.id ASC; "); try{ ResultSet rs = pst.executeQuery(); try{ while(rs.next()){ System.out.println(rs.getString(1)); //valeur sentinel pour pas de groupe parent : -1 if(rs.getInt(6)!=-1){ //ll.add(new GroupeNP(rs.getInt(1), rs.getString(2), rs.getInt(3), rs.getInt(4), TypeGroupe.getType(rs.getString(5)), ll.get(rs.getInt(6)))); }else{ //ll.add(new GroupeNP(rs.getInt(1), rs.getString(2), rs.getInt(3), rs.getInt(4), TypeGroupe.getType(rs.getString(5)), null)); } //il reste a add les étudiants et mettre le sous groupe } }catch(SQLException e){ System.out.println("erreur dans la prise de resultat"); } rs.close(); }catch(SQLException e){ System.out.println("erreur dans le resultat"); } pst.close(); }catch(SQLException e){ System.out.println("erreur dans la preparation"); } cnx.close(); }catch(SQLException e){ System.out.println("Erreur dans la connexion!"); } }catch(ClassNotFoundException e){ System.out.println("pilote non disponible"); } return null; } }