Package tk.airshipcraft.commonlib.db
Class DatabaseConfig
java.lang.Object
tk.airshipcraft.commonlib.db.DatabaseConfig
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 Summary
ConstructorsConstructorDescriptionInitializes a new DatabaseConfig object with empty properties. -
Method Summary
Modifier and TypeMethodDescriptionGets the JDBC URL from the properties.Gets the maximum pool size from the properties.Gets the database password from the properties.getProperty
(String key) Gets the value of a configuration property.Gets the Redis server password from the properties.Gets the Redis server URI from the properties.Gets the database username from the properties.void
loadFromFile
(String filePath) Loads database configuration properties from a specified file.void
setJdbcUrl
(String jdbcUrl) Sets the JDBC URL in the properties.void
setMaximumPoolSize
(String maximumPoolSize) Sets the maximum pool size in the properties.void
setPassword
(String password) Sets the database password in the properties.void
setProperty
(String key, String value) Sets the value of a configuration property.void
setRedisPassword
(String redisPassword) Sets the Redis server password in the properties.void
setRedisUri
(String redisUri) Sets the Redis server URI in the properties.void
setUsername
(String username) Sets the database username in the properties.
-
Constructor Details
-
DatabaseConfig
public DatabaseConfig()Initializes a new DatabaseConfig object with empty properties.
-
-
Method Details
-
loadFromFile
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
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
Sets the value of a configuration property.- Parameters:
key
- The property key.value
- The property value.
-
getJdbcUrl
Gets the JDBC URL from the properties.- Returns:
- The JDBC URL.
-
setJdbcUrl
Sets the JDBC URL in the properties.- Parameters:
jdbcUrl
- The JDBC URL to set.
-
getUsername
Gets the database username from the properties.- Returns:
- The database username.
-
setUsername
Sets the database username in the properties.- Parameters:
username
- The database username to set.
-
getPassword
Gets the database password from the properties.- Returns:
- The database password.
-
setPassword
Sets the database password in the properties.- Parameters:
password
- The database password to set.
-
getMaximumPoolSize
Gets the maximum pool size from the properties.- Returns:
- The maximum pool size.
-
setMaximumPoolSize
Sets the maximum pool size in the properties.- Parameters:
maximumPoolSize
- The maximum pool size to set.
-
getRedisUri
Gets the Redis server URI from the properties.- Returns:
- The Redis server URI.
-
setRedisUri
Sets the Redis server URI in the properties.- Parameters:
redisUri
- The Redis server URI to set.
-
getRedisPassword
Gets the Redis server password from the properties.- Returns:
- The Redis server password.
-
setRedisPassword
Sets the Redis server password in the properties.- Parameters:
redisPassword
- The Redis server password to set.
-