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
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Build a Query in MuleSoft With Optional Parameters
  • Monitoring Postgres on Heroku
  • On-Premises Legacy Oracle Database to PostgreSQL Database as a Service
  • Connecting Snowflake With MuleSoft Database Connector

Trending

  • Introducing Graph Concepts in Java With Eclipse JNoSQL, Part 2: Understanding Neo4j
  • Monoliths, REST, and Spring Boot Sidecars: A Real Modernization Playbook
  • Is Big Data Dying?
  • Using Python Libraries in Java
  1. DZone
  2. Data Engineering
  3. Databases
  4. MuleSoft: Connect PostgreSQL Database and Call PostgreSQL Function

MuleSoft: Connect PostgreSQL Database and Call PostgreSQL Function

In this article, we will explore how to connect the PostgreSQL database from the Mule application. We will also see how to call the PostgreSQL function.

By 
Saddam Shaikh user avatar
Saddam Shaikh
·
Feb. 07, 22 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
14.3K Views

Join the DZone community and get the full member experience.

Join For Free

What Is PostgreSQL?

PostgreSQL is an open source object-relational database system that uses and extends the SQL language to store and scale complicated data workloads.

A prerequisite to start with this walkthrough is to have a database connector added in Anypoint Studio. You can add these connectors from the Add modules option. Also, you need to have an ElephantSQL account, as we are going to use the PostgreSQL database hosted on the ElephantSQL platform. You can use any other PostgreSQL service provider platform or self-managed PostgreSQL server.

Let's configure the database connector step by step to connect to PostgreSQL:

  1. Select the Generic Connection from the Connection dropdown.
  2. Click on Configure JDBC Driver and select the Add Maven dependency option.
  3. Search for PostgreSQL dependency. Add it, and click on the Finish button to download the dependency.Search Maven Central
  4. Provide the below connection details to connect to the database instance and click on Test Connection to check connectivity.
    • URL - jdbc:postgresql://<<host>>:<<port>>/<<databaseName>>
    • Driver class name - org.postgresql.Driver
    • User - Username
    • Password - Password Test Connection Successful

          In ElephantSQL, you can get database connection details in the Details section.

ElephantSQL Details

Let's create a PostgreSQL function that will add 2 numbers and return the sum of them. In ElephantSQL's browser section, you can execute SQL script to create a function in PostgreSQL.

Create a function in PostgreSQL


SQL
 
CREATE FUNCTION addition(num1 integer, num2 integer) RETURNS integer
    AS 'select num1 + num2;'
    LANGUAGE SQL
    IMMUTABLE
    RETURNS NULL ON NULL INPUT;


No errors (Console)

Body - Addition

Hope you enjoyed reading this article.

PostgreSQL Database connection MuleSoft

Opinions expressed by DZone contributors are their own.

Related

  • Build a Query in MuleSoft With Optional Parameters
  • Monitoring Postgres on Heroku
  • On-Premises Legacy Oracle Database to PostgreSQL Database as a Service
  • Connecting Snowflake With MuleSoft Database Connector

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

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 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!