DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • SharePoint Integration With MuleSoft
  • PostgreSQL vs Oracle: When Higher Cost Means Better Performance
  • Seeding Postgres When Your Schema Has Foreign-Key Cycles
  • Generate Random Test Data in PostgreSQL

Trending

  • OpenCode: Setting Up an Open-Source AI Coding Assistant
  • YAGNI in the Age of AI Coding
  • Data Integration Landscape 2026: Event Streaming, API, and Batch in the Era of Agentic AI
  • How to Keep AI Agents From Going Rogue Using Docker Sandbox

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Data Engineering
  3. Databases
  4. Connect the MuleSoft Database Connector to Heroku Postgres

Connect the MuleSoft Database Connector to Heroku Postgres

Let's see how to connect the MuleSoft database connector to Heroku Postgres.

By 
Dejim Juang
·
Updated Mar. 12, 20 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
35.7K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

The MuleSoft Database Connector provides the ability to easily connect to any database as long as you have the JDBC driver. Here’s a quick post/walk-through on how to configure the connector to connect to Heroku Postgres. This post assumes you have a Heroku account with Postgres already added and configured. You also have Anypoint Studio 7.x installed. To start, let’s build a simple Mule flow with the following components:

Example Mule flow
Example Mule flow
You may also like: Mule 4: Database Connector Bulk Insert

The flow will listen for an HTTP request, make a call to Heroku Postgres, and return the data in JSON format. We’ll keep the listener simple and use the defaults, localhost and port 8081. For the path, we’ll use /post so the config looks like the following:

Example config
Example config

Next, let’s configure the Database Connector. Under Basic Settings, click on the green plus sign to add a new configuration. Change the Connection drop down to Generic Connection then click on Configure…for the JDBC Driver field and then click on Add Maven dependency.

Paste the following snippet into the text box on the right of the Maven dependency dialog box

XML
 




xxxxxxxxxx
1


 
1
<dependency>  
2
<groupId>org.postgresql</groupId>  
3
<artifactId>postgresql</artifactId>  
4
<version>42.2.1</version>
5
</dependency>



It should look like the following:

Maven dependency

Maven dependency

Click on Finish.

Back in the Global Element Properties dialog window. Fill in the URL, Driver class name, User, and Password fields with your credentials from Heroku Postgres.

You can find your credentials in Heroku Postgres under Settings > Database Credentials. Just click on View Credentials to see the host, database, port, username, and password.

Credentials in Heroku

Credentials in Heroku

The URL should be in the following format below. The sslmode field is required.

 jdbc:postgresql://:/?sslmode=require 

The Driver class name should be org.postgresql.Driver

Your configuration should look like the following below. Click on Test Connection… to make sure everything was configured correctly.

Database configuration

Database configuration

Once you click OK, fill in the SQL Query Text field with a valid SQL query that returns data back from your Heroku Postgres database.

The last thing we need to configure is the Transform Message to convert the data from the database to JSON. Use the following DataWeave script

Plain Text
 




xxxxxxxxxx
1


 
1
%dw 2.0
2
output application/json
3
---
4
payload



It should look like the following:

Transforming messages

Transform messages

And that’s it! I’ll leave it up to you to run and test the flow from your browser. The hardest part was figuring out the Database URL connection string. Let me know if you have any questions or run into any issues.

Versions

  • Anypoint Studio 7.3.4
  • Postgresql JDBC Driver 42.2.1
  • Mule Server 4.2.0 EE

Further Reading

Mule 4: Database Connector (Part 1).

Connecting to MS SQL Server With MuleSoft.

Database PostgreSQL Connector (mathematics) MuleSoft

Published at DZone with permission of Dejim Juang. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • SharePoint Integration With MuleSoft
  • PostgreSQL vs Oracle: When Higher Cost Means Better Performance
  • Seeding Postgres When Your Schema Has Foreign-Key Cycles
  • Generate Random Test Data in PostgreSQL

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • 🔥 ข่าวด่วน: articles/configure the mulesoft database connector to conne - ประเด็นร้อน
  • 🔥 ข่าวด่วน: articles/configure the mulesoft database connector to conne - ประเด็นร้อน
  • 🔥 ข่าวด่วน: articles/configure the mulesoft database connector to conne - ประเด็นร้อน

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • 🔥 ข่าวด่วน: articles/configure the mulesoft database connector to conne - ประเด็นร้อน
  • 🔥 ข่าวด่วน: articles/configure the mulesoft database connector to conne - ประเด็นร้อน
  • 🔥 ข่าวด่วน: articles/configure the mulesoft database connector to conne - ประเด็นร้อน