Class DatabaseConfig

java.lang.Object
tk.airshipcraft.commonlib.db.DatabaseConfig

public class DatabaseConfig extends Object
Manages database configuration settings, providing methods to load from external sources and to access individual configuration properties. This class facilitates the setup of database connections by allowing dynamic configuration management.
Since:
2023-12-27
Version:
1.0.0
Author:
notzune
  • Constructor Details

    • DatabaseConfig

      public DatabaseConfig()
      Initializes a new DatabaseConfig object with empty properties.
  • Method Details

    • loadFromFile

      public void loadFromFile(String filePath) throws IOException
      Loads database configuration properties from a specified file. This method reads a properties file from the given file path and loads the configuration settings into the properties object.
      Parameters:
      filePath - The path to the configuration file.
      Throws:
      IOException - If an error occurs during reading the file.
    • getProperty

      public String getProperty(String key)
      Gets the value of a configuration property.
      Parameters:
      key - The property key.
      Returns:
      The property value or null if the property is not found.
    • setProperty

      public void setProperty(String key, String value)
      Sets the value of a configuration property.
      Parameters:
      key - The property key.
      value - The property value.
    • getJdbcUrl

      public String getJdbcUrl()
      Gets the JDBC URL from the properties.
      Returns:
      The JDBC URL.
    • setJdbcUrl

      public void setJdbcUrl(String jdbcUrl)
      Sets the JDBC URL in the properties.
      Parameters:
      jdbcUrl - The JDBC URL to set.
    • getUsername

      public String getUsername()
      Gets the database username from the properties.
      Returns:
      The database username.
    • setUsername

      public void setUsername(String username)
      Sets the database username in the properties.
      Parameters:
      username - The database username to set.
    • getPassword

      public String getPassword()
      Gets the database password from the properties.
      Returns:
      The database password.
    • setPassword

      public void setPassword(String password)
      Sets the database password in the properties.
      Parameters:
      password - The database password to set.
    • getMaximumPoolSize

      public String getMaximumPoolSize()
      Gets the maximum pool size from the properties.
      Returns:
      The maximum pool size.
    • setMaximumPoolSize

      public void setMaximumPoolSize(String maximumPoolSize)
      Sets the maximum pool size in the properties.
      Parameters:
      maximumPoolSize - The maximum pool size to set.
    • getRedisUri

      public String getRedisUri()
      Gets the Redis server URI from the properties.
      Returns:
      The Redis server URI.
    • setRedisUri

      public void setRedisUri(String redisUri)
      Sets the Redis server URI in the properties.
      Parameters:
      redisUri - The Redis server URI to set.
    • getRedisPassword

      public String getRedisPassword()
      Gets the Redis server password from the properties.
      Returns:
      The Redis server password.
    • setRedisPassword

      public void setRedisPassword(String redisPassword)
      Sets the Redis server password in the properties.
      Parameters:
      redisPassword - The Redis server password to set.