diff --git a/src/ExercicesTP/Helpers/TableModel.java b/src/ExercicesTP/Helpers/TableModel.java index 0116f37..fe098a4 100644 --- a/src/ExercicesTP/Helpers/TableModel.java +++ b/src/ExercicesTP/Helpers/TableModel.java @@ -11,6 +11,7 @@ import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Objects; public class TableModel extends AbstractTableModel { ArrayList data; @@ -22,11 +23,7 @@ public TableModel(ResultSet rs, FormationDAO dao){ this.dao = dao; try { rsmd = rs.getMetaData(); - Object[] ligne = new Object[rsmd.getColumnCount()]; - for (int i = 0; i < rsmd.getColumnCount(); i++) { - ligne[i] = rsmd.getColumnName(i+1); - } - data.add(ligne); + } catch (SQLException e) { throw new RuntimeException(e); } @@ -36,7 +33,6 @@ public TableModel(ResultSet rs, FormationDAO dao){ Object[] ligne = new Object[rsmd.getColumnCount()]; for(int i = 0;i(); + try { + rsmd = rs.getMetaData(); + } catch (SQLException e) { + throw new RuntimeException(e); + } + try { + while (rs.next()) { + Object[] ligne = new Object[rsmd.getColumnCount()]; + for(int i = 0;i{ + String rq = "SELECT * FROM FORMATION WHERE "; + if(!titleField.getText().isEmpty()){ + rq += "titre = '"+titleField.getText()+"' AND "; + } + if(!dateTextField.getText().isEmpty()){ + rq += "datef = '"+dateTextField.getText()+"' AND "; + } + if(!lieuTextField.getText().isEmpty()){ + rq += "lieu = '"+lieuTextField.getText()+"' AND "; + } + rq = rq.substring(0, rq.length()-4); + model.updateTableWithNewResultSet(formationDAO.selection(rq)); + }); + } } diff --git a/src/TP_Base/GestionEtudiant.java b/src/TP_Base/GestionEtudiant.java index 64581b5..71479c1 100644 --- a/src/TP_Base/GestionEtudiant.java +++ b/src/TP_Base/GestionEtudiant.java @@ -6,7 +6,6 @@ import java.awt.event.MouseEvent; import java.sql.ResultSet; -import static java.lang.Integer.parseInt; public class GestionEtudiant extends JFrame { JPanel northPannel;