title: AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0 error for JTable
body: <p>I am trying to select date from my SQL database and put into a <em>JTable</em>, but I keep getting an error:</p>
  
  <blockquote>
    <p>'AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0'</p>
  </blockquote>
  
  <p>Not really sure why. This is my code:</p>
  
  <pre><code>table = new JTable();
  
  try {
      Connection MyConn = null;
      Statement statement = null;
      ResultSet rs = null;
  
      Class.forName("com.mysql.jdbc.Driver");
      MyConn = DriverManager.getConnection("jdbc:mysql:"
              + "//localhost/eventbooking", "root", "Passw0rd");
      statement = MyConn.createStatement();
      rs = statement.executeQuery("SELECT * FROM `events` WHERE `Date Of Event` = '30/03/2014'");
      int i=0;
      while (rs.next()) {
          Object a = rs.getString("Date Of Event");
          Object b = rs.getString("Tickets Available");
          Object c = rs.getString("Price Of Event");
          Object d = rs.getString("Start Time");
  
          table.setRowSorter(null);
          table.getModel().setValueAt(a, i, 0 );
          table.getModel().setValueAt(b, i, 1);
          table.getModel().setValueAt(c, i, 2);
          table.getModel().setValueAt(d, i, 3);
          EventDiary.this.add(table);         
          System.out.println(i);
          i++;
      }
  </code></pre>