VOOZH about

URL: https://www.cdata.com/kb/tech/eloquareporting-jdbc-aws-glue.rst

⇱ How to Work with Oracle Eloqua Reporting Data in AWS Glue Jobs Using JDBC


How to Work with Oracle Eloqua Reporting Data in AWS Glue Jobs Using JDBC

👁 Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Connect to Oracle Eloqua Reporting from AWS Glue jobs using the CData JDBC Driver hosted in Amazon S3.

AWS Glue is an ETL service from Amazon that allows you to easily prepare and load your data for storage and analytics. Using the PySpark module along with AWS Glue, you can create jobs that work with data over JDBC connectivity, loading the data directly into AWS data stores. In this article, we walk through uploading the CData JDBC Driver for Oracle Eloqua Reporting into an Amazon S3 bucket and creating and running an AWS Glue job to extract Oracle Eloqua Reporting data and store it in S3 as a CSV file.

Upload the CData JDBC Driver for Oracle Eloqua Reporting to an Amazon S3 Bucket

In order to work with the CData JDBC Driver for Oracle Eloqua Reporting in AWS Glue, you will need to store it (and any relevant license files) in an Amazon S3 bucket.

  1. Open the Amazon S3 Console.
  2. Select an existing bucket (or create a new one).
  3. Click Upload
  4. Select the JAR file (cdata.jdbc.oracleeloquareporting.jar) found in the lib directory in the installation location for the driver.

Configure the Amazon Glue Job

  1. Navigate to ETL -> Jobs from the AWS Glue Console.
  2. Click Add Job to create a new Glue job.
  3. Fill in the Job properties:
    • Name: Fill in a name for the job, for example: OracleEloquaReportingGlueJob.
    • IAM Role: Select (or create) an IAM role that has the AWSGlueServiceRole and AmazonS3FullAccess permissions policies. The latter policy is necessary to access both the JDBC Driver and the output destination in Amazon S3.
    • Type: Select "Spark".
    • Glue Version: Select "Spark 2.4, Python 3 (Glue Version 1.0)".
    • This job runs: Select "A new script to be authored by you".
      Populate the script properties:
      • Script file name: A name for the script file, for example: GlueOracleEloquaReportingJDBC
      • S3 path where the script is stored: Fill in or browse to an S3 bucket.
      • Temporary directory: Fill in or browse to an S3 bucket.
    • Expand Security configuration, script libraries and job parameters (optional). For Dependent jars path, fill in or browse to the S3 bucket where you uploaded the JAR file. Be sure to include the name of the JAR file itself in the path, i.e.: s3://mybucket/cdata.jdbc.oracleeloquareporting.jar
  4. Click Next. Here you will have the option to add connection to other AWS endpoints. So, if your Destination is Redshift, MySQL, etc, you can create and use connections to those data sources.
  5. Click "Save job and edit script" to create the job.
  6. In the editor that opens, write a python script for the job. You can use the sample script (see below) as an example.

Sample Glue Script

To connect to Oracle Eloqua Reporting using the CData JDBC driver, you will need to create a JDBC URL, populating the necessary connection properties. Additionally, you will need to set the property in the JDBC URL (unless you are using a Beta driver). You can view the licensing file included in the installation for information on how to set this property.

Oracle Eloqua Reporting supports the following authentication methods:

  • Basic authentication (User and Password)
  • OAuth 2.0 code grant flow
  • OAuth 2.0 password grant flow

Basic Authentication (User and Password)

To perform authentication with a user and password, specify these properties:

  • AuthScheme: Basic.
  • Company: The company name associated with your Oracle Eloqua Reporting account.
  • User: Your login account name.
  • Password: Your login password.

OAuth Authentication (Code Grant Flow)

To authenticate with the OAuth code grant flow, you must set AuthScheme to OAuth and create a custom OAuth application. For information about how to create a custom OAuth application, see the Help documentation.

Then set the following properties:

  • InitiateOAuth: GETANDREFRESH. Used to automatically get and refresh the OAuthAccessToken.
  • OAuthClientId: The client Id assigned when you registered your application.
  • OAuthClientSecret: The client secret that was assigned when you registered your application.
  • CallbackURL: The redirect URI that was defined when you registered your application.

When you connect, the driver opens Oracle Eloqua Reporting's OAuth endpoint in your default browser. Log in and grant permissions to the application. When the access token expires, the driver refreshes it automatically.

OAuth Authentication (Password Grant Flow)

With the OAuth password grant flow, you can use your OAuth application's credentials alongside your user credentials to authenticate without the need to grant permission manually via a browser prompt. You must create an OAuth app (see the Help documentation) to use this authentication method.

Set the following properties:

  • AuthScheme: OAuthPassword
  • Company: The company's unique identifier.
  • User: Your login account name.
  • Password: Your login password.
  • OAuthClientId: The client Id assigned when you registered your custom OAuth application.
  • OAuthClientSecret: The client secret assigned when you registered your custom OAuth application.

Built-in Connection String Designer

For assistance in constructing the JDBC URL, use the connection string designer built into the Oracle Eloqua Reporting JDBC Driver. Either double-click the JAR file or execute the JAR file from the command-line.

java -jar cdata.jdbc.oracleeloquareporting.jar

Fill in the connection properties and copy the connection string to the clipboard.

👁 Using the built-in connection string designer to generate a JDBC URL (Salesforce is shown.)

To host the JDBC driver in Amazon S3, you will need a license (full or trial) and a Runtime Key (RTK). For more information on obtaining this license (or a trial), contact our sales team.

Below is a sample script that uses the CData JDBC driver with the PySpark and AWSGlue modules to extract Oracle Eloqua Reporting data and write it to an S3 bucket in CSV format. Make any necessary changes to the script to suit your needs and save the job.

import sys
from awsglue.transforms import *
from awsglue.utils import getResolvedOptions
from pyspark.context import SparkContext
from awsglue.context import GlueContext
from awsglue.dynamicframe import DynamicFrame
from awsglue.job import Job

args = getResolvedOptions(sys.argv, ['JOB_NAME'])

sparkContext = SparkContext()
glueContext = GlueContext(sparkContext)
sparkSession = glueContext.spark_session

##Use the CData JDBC driver to read Oracle Eloqua Reporting data from the table into a DataFrame
##Note the populated JDBC URL and driver class name
source_df = sparkSession.read.format("jdbc").option("url","jdbc:oracleeloquareporting:RTK=5246...;AuthScheme=Basic;User=user;Password=password;Company=MyCompany;").option("dbtable","").option("driver","cdata.jdbc.oracleeloquareporting.OracleEloquaReportingDriver").load()

glueJob = Job(glueContext)
glueJob.init(args['JOB_NAME'], args)

##Convert DataFrames to AWS Glue's DynamicFrames Object
dynamic_dframe = DynamicFrame.fromDF(source_df, glueContext, "dynamic_df")

##Write the DynamicFrame as a file in CSV format to a folder in an S3 bucket. 
##It is possible to write to any Amazon data store (SQL Server, Redshift, etc) by using any previously defined connections.
retDatasink4 = glueContext.write_dynamic_frame.from_options(frame = dynamic_dframe, connection_type = "s3", connection_options = {"path": "s3://mybucket/outfiles"}, format = "csv", transformation_ctx = "datasink4")

glueJob.commit()

Run the Glue Job

With the script written, we are ready to run the Glue job. Click Run Job and wait for the extract/load to complete. You can view the status of the job from the Jobs page in the AWS Glue Console. Once the Job has succeeded, you will have a CSV file in your S3 bucket with data from the Oracle Eloqua Reporting table.

Using the CData JDBC Driver for Oracle Eloqua Reporting in AWS Glue, you can easily create ETL jobs for Oracle Eloqua Reporting data, whether writing the data to an S3 bucket or loading it into any other AWS data store.

Ready to get started?

Download a free trial of the Oracle Eloqua Reporting Driver to get started:

 Download Now

Learn more:

👁 Oracle Eloqua Reporting Icon
Oracle Eloqua Reporting JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with Oracle Eloqua Reporting.