Ready to get started?

Download a free trial of the Kintone Driver to get started:

 Download Now

Learn more:

Kintone  Icon Kintone JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with Kintone applications and databases.

How to work with Kintone Data in Apache Spark using SQL



Access and process Kintone Data in Apache Spark using the CData JDBC Driver.

Apache Spark is a fast and general engine for large-scale data processing. When paired with the CData JDBC Driver for Kintone, Spark can work with live Kintone data. This article describes how to connect to and query Kintone data from a Spark shell.

The CData JDBC Driver offers unmatched performance for interacting with live Kintone data due to optimized data processing built into the driver. When you issue complex SQL queries to Kintone, the driver pushes supported SQL operations, like filters and aggregations, directly to Kintone and utilizes the embedded SQL engine to process unsupported operations (often SQL functions and JOIN operations) client-side. With built-in dynamic metadata querying, you can work with and analyze Kintone data using native data types.

Install the CData JDBC Driver for Kintone

Download the CData JDBC Driver for Kintone installer, unzip the package, and run the JAR file to install the driver.

Start a Spark Shell and Connect to Kintone Data

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

    In addition to the authentication values, set the following parameters to connect to and retrieve data from Kintone:

    • Url: The URL of your account.
    • GuestSpaceId: Optional. Set this when using a guest space.

    Authenticating with Kintone

    Kintone supports the following authentication methods.

    Using Password Authentication

    You must set the following to authenticate:

    • User: The username of your account.
    • Password: The password of your account.

    Using Basic Authentication

    If the basic authentication security feature is set on the domain, supply the additional login credentials with BasicAuthUser and BasicAuthPassword. Basic authentication requires these credentials in addition to User and Password.

    Using Client SSL

    Instead of basic authentication, you can specify a client certificate to authenticate. Set SSLClientCert, SSLClientCertType, SSLClientCertSubject, and SSLClientCertPassword. Additionally, set User and Password to your login credentials.

    Built-in Connection String Designer

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

    java -jar cdata.jdbc.kintone.jar

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

    Configure the connection to Kintone, using the connection string generated above.

    scala> val kintone_df = spark.sqlContext.read.format("jdbc").option("url", "jdbc:kintone:User=myuseraccount;Password=mypassword;Url=http://subdomain.domain.com;GuestSpaceId=myspaceid").option("dbtable","Comments").option("driver","cdata.jdbc.kintone.KintoneDriver").load()
  3. Once you connect and the data is loaded you will see the table schema displayed.
  4. Register the Kintone data as a temporary table:

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

    scala> kintone_df.sqlContext.sql("SELECT CreatorName, Text FROM Comments WHERE AppId = 1354841").collect.foreach(println)

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

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