Forum Discussion
Connectivity between Fabric Notebook and Teradata database
- 1 year ago
Hi AshwiniN,
Thank you for reaching out to the Microsoft Fabric Forum Community.
The issue happens because uploading the Teradata JDBC driver to the Lakehouse doesn’t automatically make it available to Spark. You need to explicitly load it by manually configuring Spark to recognize the driver.
One way to solve this is by creating a custom Spark environment in Fabric. Go to Workspace settings, then Data Engineering/Science → Spark settings → Environment, and add the path to the JAR file (e.g., /Files/JDBC/teradata_jdbc.jar). Make sure to select this environment when running the notebook so the driver loads automatically.
Alternatively, if you want a quicker setup without changing environment settings, you can manually load the JAR file inside the notebook using command.
This approach works instantly, though you’ll need to reapply it for each new notebook session. After that, ensure your connection details server, username, password, and driver (com.teradata.jdbc.TeraDriver) are correct and test a basic query to confirm everything works.
Library management in Fabric environments - Microsoft Fabric | Microsoft Learn
Learn about library management in Fabric, including how to add public and custom libraries to your Fabric environments.
For more information refer the below link:
Library management in Fabric environments - Microsoft Fabric | Microsoft Learn
If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you.
- 1 year ago
Hi AshwiniN,
Thank you for the update. Since the previous steps didn't resolve the issue, you can manually load the Teradata JDBC driver directly within your Fabric notebook using the following method:
jar_path = "abfss://<lakehouse_name>@onelake.dfs.fabric.microsoft.com/Files/teradata_jdbc.jar"spark.sparkContext.addJar(jar_path)
print("Loaded JARs:", spark.sparkContext.getConf().get("spark.jars"))
Once the driver is loaded, you can connect to Teradata using this sample code:
jdbc_url = "jdbc:teradata://<Your_Teradata_Server>/DATABASE=<DatabaseName>,CHARSET=UTF8"
properties = {
"user": "<Your_Username>",
"password": "<Your_Password>",
"driver": "com.teradata.jdbc.TeraDriver"
}query = "(SELECT * FROM <TableName> LIMIT 10) as sample_data"
df = spark.read.jdbc(url=jdbc_url, table=query, properties=properties)
df.show()If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you.
Thanks for your reply !
I have tried above solution but still not working, can you please provide sample code or any documentation for reference?