title: Have additional columns when add data from database to jtable
body: <p>I write a code that add/delete data from database to JTable which has 3 columns when User press "Add" or "Delete" Button (JtoggleButton) and then press the buttons(JButton) that their labels are the number from 1 to 9.</p>
  
  <p>Here the user interface of the code:
  <img src="https://i.stack.imgur.com/ZUN1F.jpg" alt="enter image description here"></p>
  
  <p>When I try to add data to the table in the first time, it's ok and the number of columns is still 3 columns:
  <img src="https://i.stack.imgur.com/OE0qD.jpg" alt="enter image description here"></p>
  
  <p>But when I add data in the second or third time continuously , there are more 3 extra blank columns added into the table too which I don't need it.:
  <img src="https://i.stack.imgur.com/TeDWs.jpg" alt="enter image description here"></p>
  
  <p>Here the code that I think the problem is occurred:</p>
  
  <pre><code>final DefaultTableModel defaultmodel2 = new DefaultTableModel();
  final JToggleButton tglbtnAdd = new JToggleButton("Add");
  final JToggleButton tglbtnDelete = new JToggleButton("Delete");
  
  
      JButton button = new JButton("1");
      button.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
              try {
              Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
              Connection dbconbt1 = DriverManager.getConnection("" +"jdbc:sqlserver://localhost;databaseName=Store;user=&lt;&gt;;password=&lt;&gt;");
              Statement sqlstatement = dbconbt1.createStatement();
              ResultSet dbresultset1 = sqlstatement.executeQuery("select * from Store.dbo.Product where ProductID = 'P-1'");
              ResultSetMetaData rsmetadata = dbresultset1.getMetaData();       // Get metadata on them
              int numcols = rsmetadata.getColumnCount();    // How many columns?
  
              if(tglbtnAdd.isSelected() == true)
                { 
                  for (int i = 1; i &lt;= numcols; i++)
                  {
                      defaultmodel2.addColumn( rsmetadata.getColumnName(i));
                  }
  
                  while (dbresultset1.next())
                  {    Vector&lt;Object&gt; row = new Vector&lt;Object&gt;(numcols);
                    for (int i = 1; i &lt;= numcols; i++)
                     {
                      row.addElement( dbresultset1.getObject(i) );
                     }
                      defaultmodel2.addRow(row );
  
                  }
  
                }
              if(tglbtnDelete.isSelected() == true)
                {  
                  defaultmodel2.removeRow(0);
                }
              //  Get row
              dbresultset1.close();
              sqlstatement.close();
              dbconbt1.close();
              } catch (SQLException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
              } catch (ClassNotFoundException e) {
          // TODO Auto-generated catch block
               e.printStackTrace();
            }
          }
      }); 
  </code></pre>