How to connect PostgreSQL from Databricks

akj2784
New Contributor II

I am trying to connect PostgreSQL from Azure Databricks.

I am using the below code to connect.

jdbcHostname = "Test"

jdbcPort = 1234

jdbcDatabase = "Test1"

jdbcUrl = "jdbc:postgresql://{0}:{1}/{2}".format(jdbcHostname, jdbcPort, jdbcDatabase)

Connection was successful

connectionProps = { "user": "userid", "password": "pass!" }

Now, when I run the below command

accountDF = spark.read.jdbc(url=jdbcUrl, table="POC_TABLE", properties=connectionProps) display(accountDF)

I get the below error.

org.postgresql.util.PSQLException: FATAL: SSL connection is required. Please specify SSL options and retry.

How do I fix this error. I have SSL enabled in the postgreSQL at Azure portal.

Regards,

Akash