title: How to add multiple rows to JTable?
body: <p>I'm trying to populate a JTable from a database, but the output is still empty. Here is my code :</p>
  
  <pre class="lang-java prettyprint-override"><code>    private void buttonsearchActionPerformed(java.awt.event.ActionEvent evt)
      {
          conn = DatabaseConnection.dbConnection();
          try {
              String Sql="select idp,nomp,prix,stock from produit where codep='" 
                         + textsearch.getText() + "'";
              pst = conn.prepareStatement(Sql);
  
              ResultSet rs = pst.executeQuery();
              DefaultTableModel model = new DefaultTableModel();
              Object[] columns = {"Id Produit", "Nom Produit", "Quantité", "Prix", "Stock"};
              model.setColumnIdentifiers(columns);
              table.setModel(model);
              Object[] row = new Object[5];
  
              if (rs.next())
              {
                  row[0] = rs.getInt("idp");
                  row[1] = rs.getString("nomp");
                  //row[2] = rs.getString("");
                  row[3] = rs.getString("prix");
                  row[4] = rs.getString("stock");
                  model.addRow(row);
              }
          } catch (Exception e) {
              JOptionPane.showMessageDialog(null, e);
          }
      }                        
  </code></pre>
  
  <p>table "poduit" is :</p>
  
  <pre><code>| idp | codep | nomp | prix | stock |
  </code></pre>
  
  <p>"Quantité" in</p>
  
  <pre><code>Object[] columns = {"Id Produit", "Nom Produit", "Quantité", "Prix", "Stock"}; 
  </code></pre>
  
  <p>It meant to modify numbers of items to create a billing.</p>
  
  <p>my issue is the 2nd row is pasted right on the 1st one
  Thanks for help</p>