title: Table won't show column names and getting information from my database won't work
body: <p>I'm having issues importing data from my database as I get a NullPointer Exception when I don't see a problem with my coding. The column names in my table also don't show up when I use a 2 dimensional array which also causes problem when displaying data from the database. Is there a problem? Thank you in advance</p>
  
  <pre><code>//Says 'Connection class doesn't exist' yet works in another class I made called Queries
  final String URL="jdbc:mysql://localhost:3306/aerogames";
  final String DRIVER="com.mysql.jdbc.Driver";
  final String USERNAME="root";
  final String PASSWORD="";
  
  Connection conn=null;
  Statement st=null;
  String query;
  </code></pre>
  
  <p>/</p>
  
  <pre><code>public void GameMenu(){
      {
          GameCard=new JPanel();
          GameCard.setLayout(gridBag);
  
          tableLabel=new JLabel("MANAGE AUTHOR");
  
          insertTable=new JButton("Insert Game");
          updateTable=new JButton("Update Game");
          deleteTable=new JButton("Delete Game");
          backTable=new JButton("Go to Main Menu");
          backTable.addActionListener(this);
          Object[] col={"Author ID","First Name","Last Name"};
  
          DefaultTableModel model = new DefaultTableModel(data,col);
          table=new JTable(model)
          {
              boolean[] cellEditables={false,true,true, true}; 
  
              public boolean isCellEditable(int row,int col)
              {
                  return cellEditables[col];
              }
          };
  
          table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);        
          scroll=new JScrollPane(table);
          scroll.setPreferredSize(new Dimension(350,200));
  
          model=new DefaultTableModel(data,col);
          table.setModel(model);
  
          //             insertBtn.addActionListener(new ActionListener()
          //                 {
          //                     public void actionPerformed(ActionEvent evt)
          //                     {
          //                         insertAuthor();
          //                     }
          //                 });
          //             updateBtn.addActionListener(new ActionListener()
          //                 {
          //                     public void actionPerformed(ActionEvent evt)
          //                     {
          //                         updateAuthor();
          //                     }        
          //                 });
          //             deleteBtn.addActionListener(new ActionListener()
          //                 {
          //                     public void actionPerformed(ActionEvent evt)
          //                     {
          //                         deleteAuthor();
          //                     }            
          //                 });        
  
          createTable();
          updateTable();
  
          addComponent(tableLabel,GameCard,0,0,0,0,0,0);
          addComponent(scroll,GameCard,0,1,0,0,0,0);
          c.gridwidth=1;
          addComponent(insertTable,GameCard,0,2,0,0,0,0);
          addComponent(updateTable,GameCard,0,3,0,0,0,0);
          addComponent(deleteTable,GameCard,0,4,0,0,0,0);
          addComponent(backTable,GameCard,0,5,0,0,0,0);
  
      }
  }
  </code></pre>
  
  <p>/</p>
  
  <pre><code> public void createTable()
  {
      model=new DefaultTableModel();
      table=new JTable(model)
      {
          boolean[] cellEditables={false,true,true, true}; 
  
          public boolean isCellEditable(int row,int col)
          {
              return cellEditables[col];
          }
      };
  
      table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);        
      scroll=new JScrollPane(table);
      scroll.setPreferredSize(new Dimension(350,200));
  }
  
  public void updateTable()
  {        
      Object[][] data=q.getAllGamesByID_OA();
      Object[] colNames={"Game ID","Game Name","Game Price", "Game Stock"};
      model=new DefaultTableModel(data,colNames);
      table.setModel(model);
  }  
  </code></pre>
  
  <p>/ Null Pointer Exception error here</p>
  
  <pre><code>public Object[][] getAllGamesByID_OA()
  {
      query="select * from product_details order by product_ID";
      Object[][] data=null;
      ResultSet rs;
      try
      {
          rs=st.executeQuery(query);
          rs.last();
          int rowCount=rs.getRow();
          rs.beforeFirst();
          data=new Object[rowCount][4];
          int i=0;
          while(rs.next())
          {
              data[i][0]=rs.getInt("product_ID");
              data[i][1]=rs.getString("product_name");
              data[i][2]=rs.getInt("unit_price");
              data[i][3]=rs.getInt("quantity_in_stock");
              i++;
          }
      }
      catch(SQLException e)
      {
          JOptionPane.showMessageDialog(null,e.getMessage(),
              "SQL Error",JOptionPane.INFORMATION_MESSAGE);
      }
      return data;
  }   
  </code></pre>