bonjour,

J'essaye d'actualiser ma JTable avec un bouton.

J'ai trois table qui me permettent d'afficher les données de la BDD postgresql et je sais pas ou mettre le nouveau model parmi mes trois table et la syntaxe pour actualiser les données avec la méthodeFireTableDataChanged.

Je vous donne Mon code MainAfficheClient et j'espère avoir votre aide :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
 
public class MainAfficheClient
{
  public static void main(String[] args)
  {
    Connection conn = getConnection();
    try
    {
        Statement st = conn.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE,
                								   ResultSet.CONCUR_READ_ONLY );
 
        ResultSet rs = st.executeQuery( "SELECT * FROM tabclients" );
        AfficheClient rtm = new AfficheClient( rs );
 
        TablePanel tablePanel = new TablePanel( rtm );
 
        JFrame mainFrame = new JFrame( "Affiche table " );
        mainFrame.add( tablePanel, BorderLayout.CENTER );
        mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
        mainFrame.setSize( 640, 480 );
        mainFrame.setVisible( true );
 
 
    } 
    catch ( SQLException e )
    {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
 
  public static Connection getConnection()
    {
      Connection connection = null;
      boolean ok = false;
 
      //--- chargement en mémoire du pilote
      try
     {
       Class.forName( "org.postgresql.Driver");
       ok = true;
     } 
     catch ( ClassNotFoundException e )
     {
       System.out.println( "ERREUR chargement du pilote: pilote non trouvé" );
       e.printStackTrace();
     }
 
     //--- connexion à la base de données
     if ( ok )
     {
       try
       {
         connection = DriverManager.getConnection( "jdbc:postgresql://localhost:5433/tabclient","postgres","anissa39");
       } 
       catch ( SQLException e )
       {
         System.out.println( "ERREUR de connexion à la base de données: " + 
        		 "jdbc:postgresql://localhost:5433/tabclient" );
         e.printStackTrace();
       }
     }
 
      return connection;
    }
 
}
Merci.