title: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure - Caused by: java.net.UnknownHostException: null: unknown error
body: <p>I'm getting this error form a couple of days, without changing anything on the application.</p>
  
  <p>This is the exception, I could not find anything related to it with the </p>
  
  <pre><code>Caused by: java.net.UnknownHostException: null: unknown error
  </code></pre>
  
  <p>This is the stack trace</p>
  
  <pre><code>    com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
  
  The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
      at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
      at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:983)
      at com.mysql.jdbc.MysqlIO.&lt;init&gt;(MysqlIO.java:339)
      at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2252)
      at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2285)
      at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2084)
      at com.mysql.jdbc.ConnectionImpl.&lt;init&gt;(ConnectionImpl.java:795)
      at com.mysql.jdbc.JDBC4Connection.&lt;init&gt;(JDBC4Connection.java:44)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
      at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
      at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:400)
      at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:327)
      at java.sql.DriverManager.getConnection(DriverManager.java:664)
      at java.sql.DriverManager.getConnection(DriverManager.java:247)
      at it.besmart.parkserver.DBConnection.selectQuery(DBConnection.java:37)
      at it.besmart.parkserver.SocketClientHandler.updatePark(SocketClientHandler.java:135)
      at it.besmart.parkserver.StartServer.main(StartServer.java:31)
  Caused by: java.net.UnknownHostException: null: unknown error
      at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
      at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:907)
      at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1302)
      at java.net.InetAddress.getAllByName0(InetAddress.java:1255)
      at java.net.InetAddress.getAllByName(InetAddress.java:1171)
      at java.net.InetAddress.getAllByName(InetAddress.java:1105)
      at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:191)
      at com.mysql.jdbc.MysqlIO.&lt;init&gt;(MysqlIO.java:298)
      ... 17 more
  java.lang.NullPointerException
      at it.besmart.parkserver.StartServer.main(StartServer.java:31)
  </code></pre>
  
  <p>And the class which is making the connection is:</p>
  
  <pre><code>public class DBConnection {
      private String host;
      private String name;
      private String user;
      private String password;
      private String query;
      private String column;
  
      public DBConnection(String host, String name, String user, String password, String query, String column){
          this.host = host;
          this.name = name;
          this.user = user;
          this.password = password;
          this.query = query;
          this.column = column;
      }
      Connection conn = null;
      Statement stmt = null;
      ResultSet rs = null;
      String hostcompleto = "jdbc:mysql://"+host+":3306/"+name;
  
      public String[] selectQuery(){
          String[] result = null;
  
          try{
          Class.forName("com.mysql.jdbc.Driver").newInstance();
          conn = DriverManager.getConnection(hostcompleto, user, password);
          stmt = conn.createStatement();
          rs = stmt.executeQuery(query);
          ArrayList&lt;String&gt; list= new ArrayList&lt;String&gt;();
  
          while (rs.next()) {
                 list.add(rs.getString(column)); 
          }   
  
          result = new String[list.size()];
          result = list.toArray(result);
          for(int i =0; i&lt;result.length; i++){
                System.out.println(result[i]);
          } 
          } catch (Exception e) {
              e.printStackTrace();
          } finally {
              try { if (rs != null) rs.close(); } catch (SQLException e) { e.printStackTrace(); }
              try { if (stmt != null) stmt.close(); } catch (SQLException e) { e.printStackTrace(); }
              try { if (conn != null) conn.close(); } catch (SQLException e) { e.printStackTrace(); }
          }
          return result;
  
  
  
      }
  </code></pre>
  
  <p>The database in running and I can reach it via PHPMyadmin, it happens with every query I try, but i don't think it's a problem of query... </p>