Class SQLManager.Builder

java.lang.Object
net.blockhost.commons.database.core.SQLManager.Builder
Enclosing class:
SQLManager

public static final class SQLManager.Builder extends Object
Builder for creating SQLManager instances.
  • Method Details

    • config

      public SQLManager.Builder config(PooledDatabaseConfig config)

      Sets all database settings from a pooled database configuration.

      This sets credentials, maxPoolSize, and minIdle from the config. Any previous values for these settings will be overwritten.

      Parameters:
      config - the pooled database configuration
      Returns:
      this builder
    • poolName

      public SQLManager.Builder poolName(String poolName)

      Sets the connection pool name.

      This name will appear in thread names and JMX metrics.

      Parameters:
      poolName - the pool name
      Returns:
      this builder
    • logger

      public SQLManager.Builder logger(@Nullable Logger logger)
      Sets the logger for database messages.
      Parameters:
      logger - the logger to use
      Returns:
      this builder
    • infoLogger

      public SQLManager.Builder infoLogger(Consumer<String> infoLogger)

      Sets a custom info log consumer.

      If set, this will be used instead of the logger for info messages.

      Parameters:
      infoLogger - the info log consumer
      Returns:
      this builder
    • warningLogger

      public SQLManager.Builder warningLogger(Consumer<String> warningLogger)

      Sets a custom warning log consumer.

      If set, this will be used instead of the logger for warning messages.

      Parameters:
      warningLogger - the warning log consumer
      Returns:
      this builder
    • build

      public SQLManager build()
      Builds the SQLManager instance.
      Returns:
      a new SQLManager
      Throws:
      NullPointerException - if credentials is not set