title: "AWT-EventQueue-0" java.lang.NullPointerException error on MySQL JDBC java project
body: <p>I'm new to ubuntu, and in the last days I installed eclipse and lamp for working with a project that was already running on windows7. The problem is that the same string of connection doesn't works. Here is the piece of code in witch I try to connect:</p>
  
  <pre><code>    String stringaConn = null;
          String nomeClasse = null;
          stringaConn = "jdbc:mysql://localhost/cinemapreverificasql?user=root";
          nomeClasse = "com.mysql.jdbc.Driver";
          try {
              Class.forName(nomeClasse);
              System.out.println("forName eseguito");
          } catch (ClassNotFoundException e) {
              System.out.println("Classe nomeClasse - Driver non trovata");
          }
          try {
              f.conn = DriverManager.getConnection(stringaConn);
              System.out.println("Aperta la connessione");
          } catch (SQLException e) {
              System.out.println("Stringa di connessione errata");
          }
  </code></pre>
  
  <p>It enters in the second catch and prints the string "Stringa di connessione errata". Here is an example of output:</p>
  
  <pre><code>forName eseguito
  Stringa di connessione errata
  Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
      at gestioneDegliEventi.Gestione.windowOpened(Gestione.java:199)
      at java.awt.Window.processWindowEvent(Window.java:2048)
      at javax.swing.JFrame.processWindowEvent(JFrame.java:296)
      at java.awt.Window.processEvent(Window.java:2009)
      at java.awt.Component.dispatchEventImpl(Component.java:4861)
      at java.awt.Container.dispatchEventImpl(Container.java:2287)
      at java.awt.Window.dispatchEventImpl(Window.java:2719)
      at java.awt.Component.dispatchEvent(Component.java:4687)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
      at java.awt.EventQueue.access$200(EventQueue.java:103)
      at java.awt.EventQueue$3.run(EventQueue.java:694)
      at java.awt.EventQueue$3.run(EventQueue.java:692)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
      at java.awt.EventQueue$4.run(EventQueue.java:708)
      at java.awt.EventQueue$4.run(EventQueue.java:706)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
  </code></pre>
  
  <p>Searching on internet I tried the solution of changing the connection string in:</p>
  
  <pre><code>jdbc:mysql://localhost:3306/cinemapreverificasql?user=root
  </code></pre>
  
  <p>and give the permission with <code>sudo ufw allow 3306</code>, but the error risen is the same. What could be the error?</p>