title: prepareStatement pst throws java.lang.NullPointerException
body: <p>I'm trying to query my database and display in a combo box. But I constantly get the same error, so Im not sure now where the problem is exactly, I get java.lang.NullPointerException everytime I click on the combobox</p>
  
  <p>this is my code:</p>
  
  <p>``</p>
  
  <pre><code>  public Sell_Tick() 
    {
  
      initComponents();
  
      FillRouteCombo();
      con = CreateDB.getConnection();
  
          if(con!=null)
      {
          System.out.println("Successful DB Connection");
      }
  
  }
  private void FillRouteCombo()
      {
          try 
          {
              pst=con.prepareStatement("select * from routes");
              rst= pst.executeQuery();
              while(rst.next())
              {
                  String getroutes=rst.getString("destfrom");
  
                  destfrom.addItem(getroutes);
  
  
              }
          } catch (Exception e) {
              System.out.println(e);
          e.printStackTrace();
          }
  
      }
  </code></pre>
  
  <p>The error i get is this</p>
  
  <p><code>java.lang.NullPointerException
       Successful DB Connection
      at Sell_Tick.FillRouteCombo(Sell_Tick.java:47)
      at Sell_Tick.&lt;init&gt;(Sell_Tick.java:34)
      at StartPage.TicketOperationActionPerformed(StartPage.java:1710)
      at StartPage.access$5300(StartPage.java:52)
      at StartPage$33.actionPerformed(StartPage.java:1121)</code></p>
  
  <p>and line 47 is <code>pst=con.prepareStatement("select * from routes");</code></p>