title: addrow method in DefaultTableModel is not adding rows
body: <p>I have some data in MySQL which has to be retrieved and showed in JTable. Code I wrote for that is as follows</p>
  
  <pre><code>PreparedStatement ps = con.prepareStatement("select * from " + chosenClass     
                                            + " where subjects=?;");
  ps.setString(1, selectedGroup);
  rs = ps.executeQuery();
  rs.next();
  subjects[0] = rs.getString("sub1");
  subjects[1] = rs.getString("sub2");
  subjects[2] = rs.getString("sub3");
  subjects[3] = rs.getString("sub4");
  subjects[4] = rs.getString("sub5");
  subjects[5] = "H.V";
  
  tableModel.setColumnIdentifiers(new Object[]{"RollNo", "Name", subjects[0], subjects[1], 
  subjects[2], subjects[3], subjects[4], subjects[5]});
  
  tableModel = (DefaultTableModel) StuMarks_TBL.getModel();
  //I tried this after some help from internet
  
  String classToGet = "";
  if (chosenClass.matches("class12subjects")) {
      classToGet = "XII";
  } else if (chosenClass.matches("class11subjects")) {
      classToGet = "XI";
  }
  
   Query = "select sd.rollno, name, sub1, sub2, sub3, sub4, sub5, sub6  "
         + "from stu_details sd join stu_marks sm "
         + "where sm.rollno = sd.rollno "
         + " and sd.optionalSubject='" + selectedGroup + "' and sd.class='"      
         + classToGet + "';";
  
  rs = st.executeQuery(Query);
  
  i = 0;
  while (rs.next()) {
       tableModel.addRow(new Object[]{
                      rs.getString("rollno"),
                      rs.getString("name"),
                      rs.getString("sub1"),
                      rs.getString("sub2"),
                      rs.getString("sub3"),
                      rs.getString("sub4"),
                      rs.getString("sub5"),
                      rs.getString("sub6")});
  
  
                  //tableModel.setValueAt(1, 1, 4);
                  //When this is written, i am able to see 1 row in the output and then an array index out of exception    
  
       System.out.println(rs.getString("rollno")
                          + rs.getString("name")
                          + rs.getString("sub1")
                          + rs.getString("sub2")
                          + rs.getString("sub3")
                          + rs.getString("sub4")
                          + rs.getString("sub5")
                          + rs.getString("sub6"));
              }
  
          }
  </code></pre>
  
  <p>I am able to print all the details in the output panel by using the <strong>System.out.println</strong>. But it is not getting added into the table.</p>
  
  <p>As you can see the exception near <strong>//tableModel.setValueAt(1, 1, 4);</strong> i.e., array index out of bound with one row (zero th row) being displayed. I feel the rows are being added and then being deleted some how. I am not able figure it out. Can some one help me in this regard?</p>