OracleConfig.fromEnvironment constructor
OracleConfig.fromEnvironment()
Create configuration from environment variables
Required environment variables:
- ORACLE_USER or DB_USER: Database username
- ORACLE_PASSWORD or DB_PASSWORD: Database password
- ORACLE_CONNECTION_STRING or DB_CONNECTION_STRING: Connection string
Optional environment variables:
- ORACLE_CLIENT_LIB_PATH: Path to Oracle client library
Implementation
factory OracleConfig.fromEnvironment() {
final username = Platform.environment['ORACLE_USER'] ??
Platform.environment['DB_USER'];
final password = Platform.environment['ORACLE_PASSWORD'] ??
Platform.environment['DB_PASSWORD'];
final connectionString =
Platform.environment['ORACLE_CONNECTION_STRING'] ??
Platform.environment['DB_CONNECTION_STRING'];
final libraryPath = Platform.environment['ORACLE_CLIENT_LIB_PATH'];
if (username == null || username.isEmpty) {
throw OracleConfigurationException(
'Database username not found. Set ORACLE_USER or DB_USER environment variable.',
configKey: 'ORACLE_USER',
);
}
if (password == null || password.isEmpty) {
throw OracleConfigurationException(
'Database password not found. Set ORACLE_PASSWORD or DB_PASSWORD environment variable.',
configKey: 'ORACLE_PASSWORD',
);
}
if (connectionString == null || connectionString.isEmpty) {
throw OracleConfigurationException(
'Connection string not found. Set ORACLE_CONNECTION_STRING or DB_CONNECTION_STRING environment variable.',
configKey: 'ORACLE_CONNECTION_STRING',
);
}
return OracleConfig(
username: username,
password: password,
connectionString: connectionString,
libraryPath: libraryPath,
);
}