title: The easiest way to populate JTable from query
body: <pre><code>+-------+------+------+  
  |  name | level| score|  
  +-------+------+------+  
  |  data | data | data |  
  +-------+------+------+  
  </code></pre>
  
  <p>This is how I would like to show in <code>JTable</code>.</p>
  
  <p>//SQL  </p>
  
  <pre><code>static String[][] executeQuery(){  
    blabla;
  
    rs = stmt.executeQuery(sql);  
    int i=0;  
    while(rs.next()){  
      query[0][i++] = rs.getString("name ");  
      query[1][i] = rs.getString("level");  
      query[2][i] = rs.getString("score");  
    }  
    return query;  
  }  
  
  //MAIN  
  JPanel panel = new JPanel();
  
  String[][] getScores = executeQuery();  
  Object[][] data = getScores ;  
  String[] columnNames = {"name ","level","score"};  
  
  JTable table = new JTable (data, columnNames);  
  table.setEnabled(false);  
  panel.add(table);  
  
  JOptionPane.showMessageDialog(null, panel);
  </code></pre>
  
  <p>Result of this is is 3x3 table which is not properly oriented. Dont know why?<br>
  My question is: do you have some other example or do you see some errors i made ..<br>
  I have only this example but its too complicated for me - beginner:<br>
  <a href="http://www.rgagnon.com/javadetails/java-0309.html" rel="nofollow">http://www.rgagnon.com/javadetails/java-0309.html</a>  </p>