Ready to get started?

Learn more about the CData JDBC Driver for FedEx or download a free trial:

Download Now

Apache Spark でFedEx Data をSQL で操作

CData JDBC ドライバーを使用して、Apache Spark でFedEx Data にデータ連携。

Apache Spark は大規模データ処理のための高速で一般的なエンジンです。CData JDBC Driver for FedEx と組み合わせると、Spark はリアルタイムFedEx data にデータ連携して処理ができます。ここでは、Spark シェルに接続してFedEx data をクエリする方法について説明します。

CData JDBC Driver は、最適化されたデータ処理がドライバーに組み込まれているため、リアルタイムFedEx data と対話するための高いパフォーマンスを提供します。FedEx に複雑なSQL クエリを発行すると、ドライバーはフィルタや集計など、サポートされているSQL操作を直接FedEx にプッシュし、組込みSQL エンジンを使用してサポートされていない操作(SQL 関数やJOIN 操作)をクライアント側で処理します。組み込みの動的メタデータクエリを使用すると、ネイティブデータ型を使用してFedEx data を操作して分析できます。

CData JDBC Driver for FedEx をインストール

CData JDBC Driver for FedEx インストーラをダウンロードし、パッケージを解凍し、JAR ファイルを実行してドライバーをインストールします。

Spark Shell を起動してFedEx Data に接続

  1. Open a terminal and start the Spark shell with the CData JDBC Driver for FedEx JAR file as the jars parameter: $ spark-shell --jars /CData/CData JDBC Driver for FedEx/lib/cdata.jdbc.fedex.jar
  2. With the shell running, you can connect to FedEx with a JDBC URL and use the SQL Context load() function to read a table.

    There are five pieces of information needed in order to authenticate its actions with the FedEx service. This information is below.

    • Server: This controls the URL where the requests should be sent. Common testing options for this are: "https://gatewaybeta.fedex.com:443/xml", "https://wsbeta.fedex.com:443/xml", "https://gatewaybeta.fedex.com:443/web-service", and "https://wsbeta.fedex.com:443/web-service"
    • DeveloperKey: This is the identifier part of the authentication key for the sender's identity. This value will be provided to you by FedEx after registration.
    • Password: This is the secret part of the authentication key for the sender's identity. This value will be provided to you by FedEx after registration.
    • AccountNumber: This valid 9-digit FedEx account number is used for logging into the FedEx server.
    • MeterNumber: This value is used for submitting requests to FedEx. This value will be provided to you by FedEx after registration.
    • PrintLabelLocation: This property is required if one intends to use the GenerateLabels or GenerateReturnLabels stored procedures. This should be set to the folder location where generated labels should be stored.

    The Cache Database

    Many of the useful tasks available from FedEx require a lot of data. To ensure this data is easy to input and recall later, utilizes a cache database to make these requests. You must set the cache connection properties:

    • CacheProvider: The specific database you are using to cache with. For example, org.sqlite.JDBC.
    • CacheConnection: The connection string to be passed to the cache provider. For example, jdbc:sqlite:C:\users\username\documents\fedexcache.db

    組み込みの接続文字列デザイナー

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

    java -jar cdata.jdbc.fedex.jar

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

    scala> val fedex_df = spark.sqlContext.read.format("jdbc").option("url", "jdbc:fedex:Server='https://gatewaybeta.fedex.com:443/xml';DeveloperKey='alsdkfjpqoewiru';Password='zxczxqqtyiuowkdlkn';AccountNumber='110371337';MeterNumber='240134349'; PrintLabelLocation='C:\users\username\documents\mylabels';CacheProvider='org.sqlite.JDBC';CacheConnection='jdbc:sqlite:C:\users\username\documents\fedexcache.db';").option("dbtable","Senders").option("driver","cdata.jdbc.fedex.FedExDriver").load()
  3. Once you connect and the data is loaded you will see the table schema displayed.
  4. Register the FedEx data as a temporary table:

    scala> fedex_df.registerTable("senders")
  5. Perform custom SQL queries against the Data using commands like the one below:

    scala> fedex_df.sqlContext.sql("SELECT FirstName, Phone FROM Senders WHERE SenderID = ab26f704-5edf-4a9f-9e4c-25").collect.foreach(println)

    You will see the results displayed in the console, similar to the following:

Using the CData JDBC Driver for FedEx in Apache Spark, you are able to perform fast and complex analytics on FedEx data, combining the power and utility of Spark with your data.Download a free, 30 day trial of any of the 190+ CData JDBC Drivers and get started today.

 
 
ダウンロード