Simple Sample Application demonstrating use of Resource Providers.
- Oracle JDBC Version
ojdbc11-production
-v23.5.0.24.07
- Java Version used
21
- Oracle Autonomous Database used
19c
The following environment variables are expected by the application. In order to successfully run the application, the required environment variables below are marked and some are optional:
Variable | Required | Name | Default | Description |
---|---|---|---|---|
ORACLE_PASSWORD |
Conditional | Database Password | - | Database Credential if required |
ORACLE_USERNAME |
Conditional | Database User | Database Credentials if required, user must exist | |
COMPARTMENT_OCID |
Conditional | Compartment OCID | Compartment Oracle Cloud Identifier(OCID) in which the Oracle Database lives in, used by Access Token Provider in determining scope | |
DATABASE_OCID |
Conditional | Database OCID | Database Oracle Cloud Identifier(OCID), used by multiple providers | |
KEY_VAULT_URL |
Conditional | Azure Key Vault URL | Key Vault URL used by Azure Key Vault Providers | |
USERNAME_SECRET_NAME |
Conditional | Azure Key Vault Username Secret Name | Name of secret in Azure Key Vault used by the Azure Key Vault Username Providers | |
PASSWORD_SECRET_NAME |
Conditional | Azure Key Vault Password Secret Name | Name of secret in Azure Key Vault used by the Azure Key Vault Password Providers |
- demo-1.properties - Property file for OCI Connection TLS + OCI Connection String Providers
- demo-2.properties - Property file for OCI Connection TLS + OCI Connection String + OCI Access Token Providers
- demo-3.properties - Property file for OCI Connection TLS + OCI Connection String + Azure Key Vault Username and Password Providers
The application uses Maven to build and manage the project with its dependencies.
mvn clean package
To run the application JAR, you can run the following commmand:
java -jar target/java-basic-1.0-SNAPSHOT.jar
To run this example, in main.java, set the following environment variables referenced in the following lines, as user credentials are required.
String PASSWORD = System.getenv("ORACLE_PASSWORD");
String USERNAME = System.getenv("ORACLE_USERNAME");
Make sure the User and Password are set:
OracleDataSource ods = new OracleDataSource();
ods.setURL("jdbc:oracle:thin:@");
ods.setUser(USERNAME);
ods.setPassword(PASSWORD);
Set the following system property to the demo-1.properties file.
System.setProperty("oracle.jdbc.config.file", "properties/demo-1.properties");
This .properties
file requires the environment variable:
- DATABASE_OCID
Refer to the following documentations in regard to authentication and further configurations:
- Configuring Authentication for Resource Providers
- OCI Connection TLS Provider
- OCI Connection String Provider
To run this example, in main.java, remove or comment out the following lines as user credentials are not required.
String PASSWORD = System.getenv("ORACLE_PASSWORD");
String USERNAME = System.getenv("ORACLE_USERNAME");
Make sure the credentials are NOT set:
OracleDataSource ods = new OracleDataSource();
ods.setURL("jdbc:oracle:thin:@");
Set the following system property to the demo-2.properties file.
System.setProperty("oracle.jdbc.config.file", "properties/demo-2.properties");
This .properties
file requires the environment variable:
- DATABASE_OCID
- COMPARTMENT_OCID
Refer to the following documentations in regard to authentication and further configurations:
- Configuring Authentication for Resource Providers
- OCI Access token Provider
- Authenticating into the Database using Oracle Cloud IAM and Access Tokens
To run this example, in main.java, remove or comment out the following lines as user credentials are not required.
String PASSWORD = System.getenv("ORACLE_PASSWORD");
String USERNAME = System.getenv("ORACLE_USERNAME");
Make sure the credentials are NOT set:
OracleDataSource ods = new OracleDataSource();
ods.setURL("jdbc:oracle:thin:@");
Set the following system property to the demo-3.properties file.
System.setProperty("oracle.jdbc.config.file", "properties/demo-3.properties");
This .properties
file requires the environment variables:
- DATABASE_OCID
- KEY_VAULT_URL
- USERNAME_SECRET_NAME
- PASSWORD_SECRET_NAME
Refer to the following documentations in regard to authentication and further configurations: