R Language with JDBC Driver

This article shows how to use Treasure Data with the R language by using the RJDBC package.

Table of Contents

Tutorial Video

Here’s a video to show you how to connect to Treasure Data from R.


You can download the Treasure Data JDBC driver from the link below:

This driver only works with Treasure Data. It does not work in other environments such as your local Hadoop / Hive cluster.

Installing the RJDBC Package

First, please install the RJDBC Package as shown below:

$ R
> install.packages("RJDBC",dep=TRUE)

Issuing Queries

To issue queries, please use the RJDBC package together with the Treasure Data JDBC driver.

drv <- JDBC("com.treasuredata.jdbc.TreasureDataDriver",
conn <- dbConnect(drv,
dbGetQuery(conn, "SELECT COUNT(1) AS cnt FROM www_access")

If your account is only Batch(Hive) plan, please change type from presto to hive.

RJDBC is required to use Username and Passowrd for authentication. Currently, APIKEY is not supported.

Last modified: Mar 23 2017 16:15:50 UTC

If this article is incorrect or outdated, or omits critical information, please let us know. For all other issues, please see our support channels.