public class DBConfiguration extends Object
| Constructor and Description |
|---|
DBConfiguration() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addConnectionConfig(ConnectionConfig connectionConfig)
Adds a new connection config for an environment.
|
static void |
addConnectionConfig(ConnectionConfig connectionConfig,
boolean override)
Deprecated.
|
static void |
clearConnectionConfigs()
Clears connection configs for current environment
|
protected static void |
clearConnectionConfigs(String env) |
static List<ConnectionConfig> |
getConnectionConfigs(String env)
Provides a list of all connection configs corresponding to a given environment.
|
static List<ConnectionConfig> |
getConnectionConfigsExceptTesting(String dbName)
Returns all connections which correspond dbName and current environment
|
static List<ConnectionConfig> |
getConnectionConfigsForCurrentEnv()
Provides a list of all connection configs corresponding to a current environment.
|
List<ConnectionConfig> |
getTestConnectionConfigs() |
static void |
loadConfiguration(String file)
Configures multiple database connections from a single property file.
|
static void |
resetConnectionConfigs() |
public static void addConnectionConfig(ConnectionConfig connectionConfig, boolean override)
addConnectionConfig(ConnectionConfig).override - is irrelevant. This method will always override previous configurations for the same environment and with the same name.public static void addConnectionConfig(ConnectionConfig connectionConfig)
connectionConfig - connection configuration objectpublic static List<ConnectionConfig> getConnectionConfigsForCurrentEnv()
public static List<ConnectionConfig> getConnectionConfigs(String env)
env - name of environment, such as "development", "production", etc.public static List<ConnectionConfig> getConnectionConfigsExceptTesting(String dbName)
public static void clearConnectionConfigs()
public static void resetConnectionConfigs()
protected static void clearConnectionConfigs(String env)
public static void loadConfiguration(String file)
development.driver=com.mysql.cj.jdbc.Driver
development.username=john
development.password=pwd
development.url=jdbc:mysql://localhost/proj_dev
test.driver=com.mysql.cj.jdbc.Driver
test.username=mary
test.password=pwd1
test.url=jdbc:mysql://localhost/test
production.jndi=java:comp/env/jdbc/prod
# this one is to run migrations in production remotely
production.remote.driver=com.mysql.cj.jdbc.Driver
production.remote.username=root
production.remote.password=xxx
production.remote.url=jdbc:mysql://127.0.0.1:3307/poj1_production
Rules and limitations of using a file-based configuration:
file - path to a file. Can be located on classpath, or on a file system. First searched on classpath,
then on file system.public List<ConnectionConfig> getTestConnectionConfigs()
ConnectionConfig objects that are marked for testing.Copyright © 2022 JavaLite. All rights reserved.