Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Establishing Connection For Oracle EBS from Fabric

Hi team   I was working on to establish connection from Oracle EBS to fabric. I have established a Oracle Data Gateway, Hwn using this gateway i was able to connect to the Oracle using Data flow ge...
  • Anonymous's avatar
    Anonymous
    2 years ago

    HI Anonymous,

    I'd like to suggest you try to use jdbc to connect to the data source: (upload the driver file to the environment than you can invoke it in the spark config)

    # Import necessary libraries
    from pyspark.sql import SparkSession
    
    # Create a Spark session and config driver
    spark = SparkSession.builder \
        .appName("OracleTest") \
        .config("spark.driver.extraClassPath", "/path/to/your/uploaded/ojdbc11.jar") \
        .getOrCreate()
    
    # JDBC connection and properties
    jdbc_url = "jdbc:oracle:thin:@//host:1521/db"
    
    connection_properties = {
        "user": "<your_username>",
        "password": "<your_password>",
        "driver": "oracle.jdbc.driver.OracleDriver"
    }
    
    #query
    query = "SELECT * FROM your_table"
    
    # Read data from JDBC source
    df = spark.read.jdbc(url=jdbc_url, table=query, properties=connection_properties)
    
    # Show the data
    df.show()
    

    python - How to use JDBC source to write and read data in (Py)Spark? - Stack Overflow

    Regards,

    Xiaoxin Sheng