Connecting Heroku Postgresql Database To MuleSoft- Part 1 (Without Client Security Certificates)

Author: Ashish Singh Chauhan

Introduction 

Heroku Postgres is a managed SQL database service provided directly by Heroku. You can access a Heroku Postgres database from any language with a PostgreSQL driver, including all languages officially supported by Heroku.

In this blog, I will show you how to connect with the heroku postgresql database without client security certificates.

Steps of connection 
  1. Add a listener to trigger your flow and configure it.
  1. Add a Database module in your Mule palette.

Mule palette → Add modules → Database and drop in palette.

  1. For Setup connection get your connection details from Heroku postgres.

Go to heroku postgres → Settings → Database credentials → View credentials.

  1. Save connection details i.e Host, Port, Database Name, Username, Password.
  1. Add the following dependency in pom.xml →

<dependency>  

<groupId>org.postgresql</groupId>  

<artifactId>postgresql</artifactId>  

<version>42.2.1</version>

</dependency>

  1. Go to global elements → create → Connector configuration → Database config → Select generic connection.
  1. Configure Url as follows →

jdbc:postgresql://<host>:<port>/<database name>?sslmode=require

Replace your <host>, <port>, <database name> with credentials saved in step 4.

Driver class name – org.postgresql.Driver

Username – <<username>>

Password – <<password>>

After configuring the test connection.

Note – sslmode are of various types, require will make bypass the Certificates verification since we are making this connection without that.

  1. Add Select component in Mule Flow and write your query in it.
  1. Run your Mule application and hit the endpoint. You will see the data in your postman.

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.