Azure Synapse Analytics currently does not natively support connecting to Oracle databases using Linked Services directly in notebooks via mssparkutils.credentials.getConnectionStringOrCreds
since it is primarily designed for Azure-based services like Azure SQL Database or Azure Blob Storage.
Try to download the Oracle JDBC driver (ojdbc8.jar) from the Oracle website.
Since, then upload the ojdbc8.jar file to your Synapse Workspace's Linked Storage Account or any accessible storage location.
Then specify the location of the ojdbc8.jar file when starting your Synapse Spark notebook session or use the --jars option.
Then replace the code using mssparkutils.credentials with direct JDBC configurations :
from pyspark.sql import SparkSession
# Oracle database connection details
jdbc_url = "jdbc:oracle:thin:@testdb123.test.local:1521:DB01"
database_properties = {
"user": "your_username", # Replace with your Oracle DB username
"password": "your_password", # Replace with your Oracle DB password
"driver": "oracle.jdbc.OracleDriver"
}
# Read data from Oracle table
df = spark.read \
.format("jdbc") \
.option("url", jdbc_url) \
.option("dbtable", "Tablename") \
.options(**database_properties) \
.load()
# Show data
df.show()