Starting from version 23.3, the JDBC Driver can be extended through the Java Service Provider Interface (SPI).
Amongst other extensions, this allows third-party entities to provide connection properties (including sensitive information such as passwords and wallets), simplifying configuration, and secret management.
Follow the diagram below for the suggested approach:
The advanges of this approach are the following:
Besides allowing third parties and users to build their own providers, Oracle is distributing pre-built providers. Some of them are built-in the JDBC Driver (no extra jar required) and also external ones. These extensions are open-source on GitHub: https://github.com/oracle/ojdbc-extensions and the artifacts are available on MavenCentral. Please refer to the project for code samples and maven coordinates.
The Oracle DataSource uses a new prefix jdbc:oracle:thin:@config-azure:// to be able to identify that the configuration parameters should be loaded using Azure App Configuration. Users only need to indicate the App Config's name, a prefix for the key-names and the Label (both optionally) with the following syntax:
jdbc:oracle:thin:@config-azure://{appconfig-name}[?key=prefix&label=value&option1=value1&option2=value2...]
This will allow existing applications to use this feature transparently, the only requirements would be to include the provider's jar in the classpath (or the reference in the pom file) and replace the URL with the required values.
With this approach we attach values of a DataSource to a key (prefix of multiple keys in App Config) and a label (both optionally, otherwise it will attach all the values with no labels or prefixes in the configuration).
There are 4 fixed values that are looked at with this key/label.
The rest are dependent on the JDBC Driver, adding the jdbc/ prefix. We use reflection to retrieve multiple key-values pairs for a specific label and key that are applied to a DataSource. The key values are the properties (constant keys) defined in the OracleConnection interface.
As an example, a datasource URL with the value jdbc:oracle:thin:@config-azure://myappconfig?key=/sales_app1/&label=dev in an App Config name 'myappconfig' with the values below will generate an OracleDatasource with (note the prefix '/sales_app1/' and label 'dev'):
Note: in the JDBC Driver we concatenate the connect descriptor with 'jdbc:oracle:thin:@' internally to set the URL. This is to be able to share the property with other driver implementations.
For this example we copied the "Connection String" that is available in the "DB Connection" tab of the tested Autonomous Database.
Please also note that in App Config Explorer we can have multiple Keys and Labels, for this URL in the example only the ones with the /sales_app1/ prefix and label dev will be picked by the driver for this Datasource.
In this case, the configuration is stored in JSON format (just like with Azure, the format is common to all the clients) where the provider is identified by 'ociobject' provider in the URL: Eg: jdbc:oracle:thin:@config-ociobject://objectstorage.us-phoenix-1.oci.customer-oci.com/n/mytenancy/b/bucket1/o/payload_ojdbc_objectstorage.json
The only required parameter is the object's URL Path (URI). Users can retrieve this value by navigating in the OCI Web Console from: Object Storage / Buckets / Object → Object Details. A value similar to https://objectstorage.us-phoenix-1.oci.customer-oci.com/n/mytenancy/b/bucket1/o/payload_ojdbc_objectstorage.json gets selected.
Following the approach set in for the Azure App Config provider, the spec follows these rules:
There are 4 fixed values that are looked with this prefix/label.
The rest are dependent on the driver, in our case /jdbc. We use reflection to retrieve multiple key-values pairs for an specific label and prefix that are applied to a DataSource. The key values are the properties (constant keys) defined in the OracleConnection interface.
The password and wallet_location are references to a Vault provider (it can also be Azure Key Vault, using 'vault-azure' as its type.
The Database Tools Connections service is a managed service that can be used to configure "connections" to a database (ADB or mysql). This "connection" object can then be used in the sql worksheet in the web console. It can also be used as a directory of database connection configurations and a provider will allow access to these configurations. Each configuration has an OCID that is used to identify which connection is used. It contains a connectionString, userName, userPassword, keyStores and advancedProperties that, today, are limited to JDBC properties but will soon allow a free format that will work for .Net and OCI.
JDBC URL that uses the OCI DBTools provider:
jdbc:oracle:thin:@config-ocidbtools://ocid1.databasetoolsconnection.oc1.phx.ama ...
The JDBC Driver includes HTTPS and File providers (no extra jar required) based on the same JSON Schema defined in the previous chapter for OCI Object Storage. Please refer to the oracle.jdbc.spi.OracleConfigurationProvider Javadoc for more information.
The JSON configuration document may be provided through an HTTPS endpoint (for example ORDS). HTTP is not supported. Because the JSON configuration document (specified above) may contain multiple aliases, the URL must end up with the alias name that needs to be loaded: https://<URL>/aliasname.
Access to this configuration can be protected by IP ACL, TCPS and Basic HTTP Auth.
The JDBC URL would follow this format: jdbc:oracle:thin:@config-https://<URL>[?key=name&option1=value1...].
Client authentication can be configured with basic HTTP authentication over https using wallet through props.
jdbc:oracle:thin:@config-https://confighost.mydomain.com/oracleconfig?key=name&authentication=BASIC_AUTH&wallet_location=/path/to/wallet
The authentication option is used to make the https config provider use basic HTTP authentication to retrieve the JSON configuration document. Note that the https provider distributed by Oracle will support Basic HTTP Authentication.
The same JSON configuration document can also be provided through the file system.
Access to this configuration can be protected by file system protection.
The JDBC URL would follow this format: jdbc:oracle:thin:@config-file://{path-to-file}[?option list]
The {path-to-file} parameter takes the same rules the java.io.File (for the Java implementation).
The option list includes an attribute to indicate the connection key name: jdbc:oracle:thin:@config-file://path/to/file.json?key=sales_app1
Building your own provider is a very simple task in terms on how to integrate it with the JDBC Driver.
The only task you need to do is to implement the interface oracle.jdbc.spi.OracleConfigurationProvider (this interface is in the JDBC Driver) and provide an implementation for:
For example
Can be used as: