Huskehhh / MySQL

Simple JDBC MySQL database wrapper for Java
MIT License
69 stars 51 forks source link

Too many connections #30

Closed HugoSilvaF closed 2 years ago

HugoSilvaF commented 2 years ago

when i reload the minecraft server the HikariPool create a new pool connection. However when it arrives at the 20th connection, i get an error. This error: "Too many connections" image

My code of start and disable mysql:

    private void disableMySQL() {
      try {
         if (mysql != null) {
            mysql.closeConnection();
         }
      } catch (SQLException var2) {
         var2.printStackTrace();
      } 
    }

    private void startMySQL() {
        if (this.getConfig().getBoolean("mysql.enable")) {
           String url = "jdbc:mysql://" + this.getConfig().getString("mysql.host") + ":" + this.getConfig().getString("mysql.port") + "/" + this.getConfig().getString("mysql.database") + "/" + this.getConfig().getString("mysql.username") + "/" + this.getConfig().getString("mysql.password");
           mysql = new MySQL("jdbc:mysql://" + this.getConfig().getString("mysql.host") + ":" + this.getConfig().getString("mysql.port") + "/" + this.getConfig().getString("mysql.database"), this.getConfig().getString("mysql.username"), this.getConfig().getString("mysql.password"));
        }
     }

image

Huskehhh commented 2 years ago

This is not an issue with the library. You need to manage the lifecycle of the connection using the methods available on the server.