code: public final Connection getConnection() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException {
          String url = "jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database + "?user=" + this.username + "&password="
                  + this.password + "&autoReconnect=true" + "&failOverReadOnly=false&maxReconnects=3";
          DriverManager.registerDriver((Driver) Class.forName("com.mysql.jdbc.Driver").newInstance());
          return DriverManager.getConnection(url);
      }
docs: Get database connection.
  
  @return The connection
  @throws SQLException
  -
  @throws InstantiationException
  -
  @throws IllegalAccessException
  -
  @throws ClassNotFoundException
  -