title: add column to jtable dynamically on netbeans
body: <p>my code is this :</p>
  
  <pre><code>private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
      DefaultTableModel model=(DefaultTableModel)pl.getModel();               
          String urlBaseDonnes="jdbc:mysql://localhost:3306/test";
          Connection con;
          try{
          Class.forName("com.mysql.jdbc.Driver");
          }catch(ClassNotFoundException ex){
              System.out.println(ex);
          }
          try{
              con =DriverManager.getConnection(urlBaseDonnes,"root","");
          try (Statement stmt = con.createStatement()) {
              ResultSet rs = stmt.executeQuery("SELECT * FROM news");
              ResultSetMetaData rsMetaData = rs.getMetaData();
              int numberOfColumns = rsMetaData.getColumnCount();
              System.out.println("resultSet MetaData column Count=" + numberOfColumns);
              int j=0;
              pl.setModel(new javax.swing.table.DefaultTableModel(new Object [][] {},new String [] {"ddd","fgg","nl"}));
  
              // get the name of the column, and changing it
  
              for (int i = 1 ; i &lt;= numberOfColumns; i++) {
                  ChangeName(pl,j,rsMetaData.getColumnName(i));
                  System.out.println(rsMetaData.getColumnName(i));
                  System.out.println(j);
                  j= j+1;
              }
              String query="SELECT * FROM news";
              rs=stmt.executeQuery(query);
  
              //Show the database
  
              while(rs.next()){
                  String id=rs.getString("id");
                  String titre=rs.getString("titre");
                  String contenu=rs.getString("contenu");  
                  model.addRow(new Object[]{id,titre,contenu});
              }
              rs.close();
          }
          con.close();
          System.out.println("close the database");
          }catch(SQLException ex){
              System.out.println(ex);
          }
  }       
  </code></pre>
  
  <p>My goal is to change the name of the columns dynamically when i change the name of my table, this code can change the name of the column but when it's come to showing the content of the database it doesn't work, also i can't add column, for exemple if i choose a table that have 4 column, i'll have an error. I tried to add column using a DefaultTableModel but it didn't work.
  could you please help me with the part of adding column dynamically ? and tell me why this code doesn't show what's on the database ?
  Thanks</p>