title: Jtable java.lang.NullPointerException
body: <p>im not sure why update_table() is giving me java.lang.NullPointerException... need some lights.. i can establish connection to jdbc.. when im commenting out update_table() method, everything works like a charm.</p>
  
  <pre><code>public class UserMenu extends JFrame {
      private JPanel contentPane;
      private JTable userTable;
  
      Connection conn = null;
      ResultSet rs = null;
      PreparedStatement pst = null;
  
  
      private void Update_table (){
  
          try {
              String sql = "select * from login";
              pst = conn.prepareStatement(sql);
              rs = pst.executeQuery(sql);
              userTable.setModel(DbUtils.resultSetToTableModel(rs));
          } catch (SQLException e) {
              // TODO Auto-generated catch block
              //JOptionPane.showMessageDialog(null, e);
              e.printStackTrace();
          }
      }
  
      /**
       * Launch the application.
       */
      public static void main(String[] args) {
          EventQueue.invokeLater(new Runnable() {
              public void run() {
                  try {
                      UserMenu frame = new UserMenu();
                      frame.setVisible(true);
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }
          });
      }
  
      /**
       * Create the frame.
       */
      public UserMenu() {
  
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setBounds(100, 100, 450, 300);
          contentPane = new JPanel();
          contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
          setContentPane(contentPane);
          //initComponents();
          try{
              conn = JavaConnect.ConnecrDb();
              Update_table();
          }catch(NullPointerException npe)
          {
              //JOptionPane.showMessageDialog(null, e);
              npe.printStackTrace();
          }
  
  
          JButton btnNewButton = new JButton("New button");
          btnNewButton.setBounds(10, 11, 89, 23);
          btnNewButton.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent arg0) {
                  MainMenu mm = new MainMenu();
                  mm.setVisible(true);
                  mm.setExtendedState( mm.getExtendedState()|JFrame.MAXIMIZED_BOTH );
                  MainMenu.CurrentDate();
                  dispose();
              }
          });
          contentPane.setLayout(null);
          contentPane.add(btnNewButton);
  
          JScrollPane scrollPane = new JScrollPane();
          scrollPane.setBounds(51, 107, 293, 102);
          contentPane.add(scrollPane);
  
          userTable = new JTable();
          scrollPane.setViewportView(userTable);
          userTable.setModel(new DefaultTableModel(
              new Object[][] {
                  {null, null, null},
                  {null, null, null},
                  {null, null, null},
                  {null, null, null},
                  {null, null, null},
              },
              new String[] {
                  "id", "uname", "passwd"
              }
          ));
      }
  }
  </code></pre>
  
  <p>this is the error</p>
  
  <pre><code>java.lang.NullPointerException
      at UserMenu.Update_table(UserMenu.java:35)
      at UserMenu.&lt;init&gt;(UserMenu.java:75)
      at UserMenu$1.run(UserMenu.java:52)
      at java.awt.event.InvocationEvent.dispatch(Unknown Source)
      at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
      at java.awt.EventQueue.access$200(Unknown Source)
      at java.awt.EventQueue$3.run(Unknown Source)
      at java.awt.EventQueue$3.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
      at java.awt.EventQueue.dispatchEvent(Unknown Source)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.run(Unknown Source)
  </code></pre>