title: Can't establish a connection to the database
body: <p>I'm currently trying to develop a Minecraft-plugin for Bukkit.</p>
  <p>This is the code of my Database class:</p>
  <pre><code>package net.klapsenjesus.protoncore;
  
  import java.sql.Connection;
  import java.sql.DriverManager;
  
  import static org.bukkit.Bukkit.getLogger;
  
  public class Database {
      Connection connection;
  
      public Database() {
  
      }
  
      public boolean connect (String host, String database, String user, String password) {
  
          try{
              Class.forName(&quot;com.mysql.jdbc.Driver&quot;).newInstance();
              String connectionCommand = &quot;jdbc:mysql://&quot;+host+&quot;/&quot;+database+&quot;?user=&quot;+user+&quot;&amp;password=&quot;+password+&quot;&amp;autoReconnect=true&amp;failOverReadOnly=false&amp;maxReconnects=10&quot;;
              connection = DriverManager.getConnection(connectionCommand);
              getLogger().info(&quot;Die Datenbankverbindung wurde erfolgreich hergestellt.&quot;);
              return true;
  
          }catch (Exception ex){
  
  
              System.out.println(ex);
              return false;
          }
      }
  
  }
  </code></pre>
  <p>I'm calling it from my main-class in the following way:</p>
  <pre><code>String[] data = new String[4];
  
  data[0] = getConfig().getString(&quot;host&quot;);
  data[1] = getConfig().getString(&quot;database&quot;);
  data[2] = getConfig().getString(&quot;user&quot;);
  data[3] = getConfig().getString(&quot;password&quot;);
  </code></pre>
  <p>In my my.cnf i set the bind-adress to 0.0.0.0, the firewall isn't blocking any requests, MySQL is up and running. I don't have any idea where the error is.</p>
  <p>Here's the exception:</p>
  <blockquote>
  <p>Could not create connection to database server. Attempted reconnect 10
  times. Giving up. 15:58:56 WARN:    at
  sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  15:58:56 WARN:  at
  sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  15:58:56 WARN:  at
  sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  15:58:56 WARN:  at
  java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  15:58:56 WARN:  at
  com.mysql.jdbc.Util.handleNewInstance(Util.java:403) 15:58:56 WARN:
  at com.mysql.jdbc.Util.getInstance(Util.java:386) 15:58:56 WARN:
  at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
  15:58:56 WARN:  at
  com.mysql.jdbc.SQLError.createSQLException(SQLError.java:898)
  15:58:56 WARN:  at
  com.mysql.jdbc.SQLError.createSQLException(SQLError.java:887)
  15:58:56 WARN:  at
  com.mysql.jdbc.SQLError.createSQLException(SQLError.java:861)
  15:58:56 WARN:  at
  com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2095)
  15:58:56 WARN:  at
  com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2020)
  15:58:56 WARN:  at
  com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:768)
  15:58:56 WARN:  at
  com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47)
  15:58:56 WARN:  at
  sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  15:58:56 WARN:  at
  sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  15:58:56 WARN:  at
  sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  15:58:56 WARN:  at
  java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  15:58:56 WARN:  at
  com.mysql.jdbc.Util.handleNewInstance(Util.java:403) 15:58:56 WARN:
  at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:385)
  15:58:56 WARN:  at
  com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:323)
  15:58:56 WARN:  at
  java.sql.DriverManager.getConnection(DriverManager.java:664) 15:58:56
  WARN:    at
  java.sql.DriverManager.getConnection(DriverManager.java:270) 15:58:56
  WARN:    at
  net.klapsenjesus.protoncore.Database.connect(Database.java:20)
  15:58:56 WARN:  at
  net.klapsenjesus.protoncore.ProtonCore.onEnable(ProtonCore.java:34)
  15:58:56 WARN:  at
  org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263)
  15:58:56 WARN:  at
  org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:351)
  15:58:56 WARN:  at
  org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480)
  15:58:56 WARN:  at
  org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:494)
  15:58:56 WARN:  at
  org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:408)
  15:58:56 WARN:  at
  org.bukkit.craftbukkit.v1_16_R3.CraftServer.reload(CraftServer.java:881)
  15:58:56 WARN:  at org.bukkit.Bukkit.reload(Bukkit.java:651)
  15:58:56 WARN:  at
  org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:27)
  15:58:56 WARN:  at
  org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149)
  15:58:56 WARN:  at
  org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchCommand(CraftServer.java:763)
  15:58:56 WARN:  at
  org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchServerCommand(CraftServer.java:748)
  15:58:56 WARN:  at
  net.minecraft.server.v1_16_R3.DedicatedServer.handleCommandQueue(DedicatedServer.java:387)
  15:58:56 WARN:  at
  net.minecraft.server.v1_16_R3.DedicatedServer.b(DedicatedServer.java:356)
  15:58:56 WARN:  at
  net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:1008)
  15:58:56 WARN:  at
  net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:847)
  15:58:56 WARN:  at
  net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:164)
  15:58:56 WARN:  at java.lang.Thread.run(Thread.java:748) 15:58:56
  WARN: Caused by:
  com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
  Communications link failure 15:58:56 WARN:  15:58:56 WARN: The
  last packet sent successfully to the server was 0 milliseconds ago.
  The driver has not received any packets from the server. 15:58:56
  WARN:    at
  sun.reflect.GeneratedConstructorAccessor24.newInstance(Unknown Source)
  15:58:56 WARN:  at
  sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  15:58:56 WARN:  at
  java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  15:58:56 WARN:  at
  com.mysql.jdbc.Util.handleNewInstance(Util.java:403) 15:58:56 WARN:
  at
  com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990)
  15:58:56 WARN:  at com.mysql.jdbc.MysqlIO.(MysqlIO.java:335)
  15:58:56 WARN:  at
  com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2187)
  15:58:56 WARN:  at
  com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2036)
  15:58:56 WARN:  ... 31 more 15:58:56 WARN: Caused by:
  java.net.UnknownHostException: null 15:58:56 WARN:  at
  java.net.InetAddress.getAllByName0(InetAddress.java:1281) 15:58:56
  WARN:    at java.net.InetAddress.getAllByName(InetAddress.java:1193)
  15:58:56 WARN:  at
  java.net.InetAddress.getAllByName(InetAddress.java:1127) 15:58:56
  WARN:    at
  com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:188)
  15:58:56 WARN:  at com.mysql.jdbc.MysqlIO.(MysqlIO.java:299)
  15:58:56 WARN:  ... 33 more</p>
  </blockquote>