Connect Free Oracle Autonomous Database from MuleSoft

 A database is the most commonly used backend in the integration world. We often build a lot of integrations with databases (be it as a source or target system). Likewise, working on a proof-of-concept, we always find it hard to have a database that we can use on a local machine or on the cloud. If we install a database on a local device it will consume a lot of resources. Not only that connecting from a cloud integration platform i.e. MuleSoft cloudhub is always tricky.

Oracle has an always free-to-use Autonomous Database instance available on the cloud with limited features but is really a powerful database to use. We would say, it is one of the best suitable for doing proof of concepts and validation before working on an actual use case.

We thought of giving it a try to connect MuleSoft to the Free version of the Autonomous Oracle database. We created a free trial account for Oracle and an always-free autonomous database instance. Once we have the instance created, we can connect using SQL developer easily. But now the question is 

How to connect this database using MuleSoft?

Let's start with prerequisites.

Prerequisites

1. Log in to the oracle cloud instance and navigate to the autonomous database instance.

2. Click on the database connection. Then click on Download wallet.

3. Enter the wallet password (and make a note of it, which will be used in later steps)and click on Download. The wallet.zip file will be downloaded.

4. Extract the downloaded zip file. We will see below files extracted.

To connect to Oracle Autonomous Database, we can use either 
  1. mTLS, enabled by default.
  2. TLS

The below steps will be familiar to both configurations

1. To fetch the connection URLs, we can either get them from the database instance page. Click on Database connection and scroll down to connection strings.

2. Select either TLS or mTLS under TLS authentication.

3. There will be 5 TNS(database service names) names available: high, low, medium, tp, and tpurgent. Click on the show, the TNS we may want to use, and copy the string. The string will contain all the details like host, port, service name, etc.

 4. We can also get all these details from the file tnsnames.ora extracted from the wallet.

Connect using mTLS configurations

Whenever we create a new autonomous DB instance, only mTLS is enabled by default. To connect to the database, we need to configure 2 way SSL along with database credentials in MuleSoft.
  • Copy the keystore.jks and truststore.jks under the "src/main/resources" directory of the mule project. We can also keep it under a separate directory. In this example, we will be using the "wallet" folder to store these files.
  • Configure the database connection as below:
  • By providing these details, we will not be able to connect to DB as we have not configured mTLS. Click on the TLS tab and configure the details below.
Note: Keystore password, Keystore key password, and trust store password will be equal to the wallet password which we gave while generating the wallet on the OCI console.
  • Click on Test Connection, and we will see the connection is successful.

Connect using TLS configurations

To enable connectivity through TLS, we need to update the Access Control List(ACL) in the database instance under networking.

Please refer below link to configure TLS in the Oracle Autonomous database instance.

Once TLS is enabled at Oracle Cloud Autonomous database, we can configure TLS. The only difference in the configuration will be to use only the trust store instead of configuring both the key store and the trust store.


Thank you for reading and please share any thoughts or comments.



Comments

Popular posts from this blog

DateTime formatting using xp20:format-dateTime ()

Create Delimited String from XML Nodes and Vice Versa in SOA 12c

Import and Export MDS artifacts in SOA 12c