title: get data to fill JTable netbeans
body: <p>I have successfully connected to MySQL database and can print data in the command but I want to place them into a JTable. I know the following is not allowed but how can I do this;</p>
  
  <pre><code>jTable1.setValueAt(connect.rs.getString("name"), row, 0);
  jTable1.setValueAt(connect.rs.getString("price"), row, 1);
  </code></pre>
  
  <p>The correct way is;</p>
  
  <pre><code>jTable1.setValueAt(connect.rs.getString(1), row, 0);
  jTable1.setValueAt(connect.rs.getString(2), row, 1);
  </code></pre>
  
  <p>But I don't know what 1 and 2 represents.</p>
  
  <p>Really I just want to get all the data and populate the JTable with name and price variables of MySQL.</p>
  
  <p>Here is my DBConnect class;</p>
  
  <pre><code>import java.sql.*;
  
  
  public class DBConnect {
  
  private Connection con;
  private Statement st;
  public ResultSet rs;
  public String name;
  public String ph;
  public DBConnect(){
     try{
         Class.forName("com.mysql.jdbc.Driver");
  
         con = DriverManager.getConnection("jdbc:mysql://buiud.com:3306/buiud458_androidhive","XXX","XXX");
  
         st = con.createStatement();
  
     } 
     catch(Exception ex){
         System.out.println("Err: "+ex);
     }
  }
  
  public void getData(){
      try{
          String query = "select * from products";
          rs = st.executeQuery(query);
          System.out.println("Records from database");
          while(rs.next()){
              name = rs.getString("name");
              ph = rs.getString("price");
              System.out.println("Name: "+name+"    "+"Price: "+ph);
          }
      }catch(Exception ex){
          System.out.println("ERR: "+ex);
      }
  }
  }
  </code></pre>