title: NullPointerException when i try Select data from Mysql base
body: <p>I have problem. When i try select data from database i see error NullPointerException. To connect to database i use Singleton pattern.</p>
  
  <p>Singleton class :</p>
  
  <pre><code>public class Database {
  
  private static Database instance = new Database();
  
  private Connection con;
  
  private Database() {
  
  }
  
  public static Database getInstance() {
      return instance;
  }
  
  public Connection getConnection(){
      return con;
  }
  public void connect() throws Exception {
  
      if (con != null)
          return;
  
      try {
          Class.forName("com.mysql.jdbc.Driver");
      } catch (ClassNotFoundException e) {
          throw new Exception(e);
      }
  
      String url = String.format("jdbc:mysql://127.0.0.1:3306/newssystem");
  
      con = DriverManager.getConnection(url, "root","");
  }
  
  public void disconnect() {
      if (con != null) {
          try {
              con.close();
          } catch (SQLException e) {
              System.out.println("Nie można zakończyć połączenia");
          }
      }
  
      con = null;
  }
  
  }
  </code></pre>
  
  <p>Class to select data :
  public class ArtOpcje {
      public ArrayList getArtykul() throws SQLException {</p>
  
  <pre><code>    ArrayList&lt;Artykul&gt; news = new ArrayList&lt;Artykul&gt;();
  
      Connection conn = Database.getInstance().getConnection();
  
      String sql = "SELECT id, title, article FROM news";
  
      Statement pa = conn.createStatement();
  
      ResultSet results = pa.executeQuery(sql);
  
      while(results.next()) {                                     
          int id = results.getInt("id");
          String title = results.getString("title");
          String article = results.getString("article");
          Artykul artykul = new Artykul(id, title, article);  
          news.add(artykul);
      }
      results.close();
      pa.close();
      return news;
  }
  }
  </code></pre>
  
  <p>And code fragment when i use this Select in Combobox:</p>
  
  <pre><code>    combo.setBounds(150, 250, 350, 30);
      combo.removeAllItems();
      System.out.println("poza  pętlą");
      this.add(combo);
  
      ArrayList&lt;Artykul&gt; artykul = new ArrayList&lt;Artykul&gt;();
      artykul = art.getArtykul();
  
  
      String[] aa = new String[artykul.size()];
      for(int i =0; i&lt;artykul.size(); i++){
           aa[i] = artykul.get(i).getTitle();
      }
  
  
  Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
   at model.ArtOpcje.getArtykul(ArtOpcje.java:40)
   at view.View.&lt;init&gt;(View.java:82)
   at aplication.Aplication.runApp(Aplication.java:34)
   at aplication.Aplication$1.run(Aplication.java:21)
   at java.awt.event.InvocationEvent.dispatch(Unknown Source)
   at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
   at java.awt.EventQueue.access$500(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>
  
  <p>NullPointerException is here : </p>
  
  <pre><code>Statement pa = conn.createStatement();
  </code></pre>