JDBC support has been added to teradataR version 1.0.1 which provides the ability of using the Teradata JDBC Driver through teradataR to connect to the Teradata database.  teradataR allows R users to easily connect to a Teradata database and use statistical functions directly against the Teradata system without having to extract memory into data.  For more information on teradataR, refer to the teradataR User Guide.

What is R?  R is a language and environment for statistical computing and graphics that runs on UNIX, Windows, and MacOS platforms.

To set up the Teradata JDBC Driver to use with teradataR:

  1. Ensure that you have a Java Runtime Environment (JRE) installed on your client system.  Set the environment variable JAVA_HOME to the directory of the JRE. 
  2. Download and extract the Teradata JDBC Driver to a directory of your choice.  Note the directory of the extracted files as this will be used later to connect to the Teradata database as the ClasspathForTeradataJDBCDriverFiles.
  3. Download and install R[1] from http://www.r-project.org/
  4. Download and install teradataR according to the instructions in the teradataR User Guide

Ensure that the RJDBC, DBI, and rJava packages are installed according to the instructions in the teradataR User Guide in order to use JDBC.

 

Connect to the Teradata database using a teradataR JDBC session:

  1. Open the RGui
  2. Click on Packages-->Load package…
  3. Select “RJDBC” and click OK
  4. Repeat step #2
  5. Select “teradataR” and click OK

teradataR is now ready to use the Teradata JDBC driver to connect to the Teradata database.

 

 

 

Using the R Console, enter the following steps below to make a Teradata connection:

  1. drv = JDBC("com.teradata.jdbc.TeraDriver","ClasspathForTeradataJDBCDriverFiles") <enter>

         Example: drv = JDBC("com.teradata.jdbc.TeraDriver","c:\\terajdbc\\terajdbc4.jar;c:\\terajdbc\\tdgssconfig.jar")

         NOTE: A path on a UNIX machine would use single forward slashes to separate its components and a colon between files.

 

  1. conn = dbConnect(drv,"jdbc:teradata://DatabaseServerName/ParameterName=Value","User","Password") <enter>

         Example:  conn = dbConnect(drv,"jdbc:teradata://system/TMODE=ANSI","user1","password1")

         NOTE: Connection parameters are optional. The first ParameterName is separated from the DatabaseServerName by a forward slash character.

 

  1. dbGetQuery(conn,"SQLquery") <enter>

         Example: dbGetQuery(conn,"select * from dbc.dbcinfo")

 

 

To be able to specify JDBC connection URL parameters, use the JDBC and dbConnect commands as shown above instead of the the tdConnect command as specified in the teradataR User Guide.

For further examples of how to use teradataR, refer to the teradataR User Guide.


 


 

[1] This article is written using R 2.15.3 for Windows.

R 3.0.1 is not compatible with teradataR 1.0.1 and will return an error stating that teradataR was built before R 3.0.0 when trying to install teradataR.

 

 

Discussion
thedba 10 comments Joined 03/10
05 Jun 2013

The R pacackage in general has not had any updates in the last 2 years, any plans on adding more functions and supporting R 3.0.0 and above ?

ulrich 51 comments Joined 09/09
05 Jun 2013

I support this question!
Are there plans to support R 3.0.0? Or if there are no plans to work on this - why not release the source code as open source?
 

feel free to donate bitcoin:12kgAUHFUqvG2sQgaRBXFhCwyf9HXdkGud

jjordan 7 comments Joined 03/11
12 Jun 2013

Your comments have been forwarded to the teradataR team.  Thanks.

jjordan 7 comments Joined 03/11
12 Jun 2013

Response received:
 
There are no plans to release new versions of TeradataR.  Instead we are exploring other opportunities with R.  At this point there is no plan to release source code.
 

dlabar 5 comments Joined 06/11
28 Aug 2013

This is very unfortunate.
Can you comment on the "other opportunities"?  Do they involve Revolution R Enterprise?

dlabar 5 comments Joined 06/11
jjordan 7 comments Joined 03/11
24 Sep 2013

Thanks for pointing out this link.  Yes, this is the new offering for R.

ulrich 51 comments Joined 09/09
23 Oct 2013

On http://www.teradata.com/News-Releases/2013/Teradata-Offers-First-Fully-Parallel-Scalable-R-Analytics/
This is very interesting but also very different to teradataR as it requires separate licencing.

feel free to donate bitcoin:12kgAUHFUqvG2sQgaRBXFhCwyf9HXdkGud

jjordan 7 comments Joined 03/11
24 Oct 2013

Yes, the offers are different.

mcetraro 2 comments Joined 04/13
19 Nov 2013

I am trying to connect to a Teradata 13.10 using a JDBC from R and I getting this message:
> tdConnect("BOKCHOY", uid = "xxxxxx", pwd = "xxxxxx", database="fuzzylogix", dType=c("jdbc"))
Loading required package: RJDBC
Loading required package: DBI
Loading required package: rJava
Error in .jfindClass(as.character(driverClass)[1]) : class not found
 

Marco

jjordan 7 comments Joined 03/11
20 Nov 2013

In the section of the article "Using the R Console, enter the follwing steps below to make a Teradata connection",  step 1 is needed to set the classpath.
 
 

rdayan 1 comment Joined 01/14
31 Jan 2014

Getting the following message when trying to connect to Teradata 13.10 using JDBC from R:
 drv = JDBC("com.teradata.jdbc.TeraDriver","c:\\Downloads\\TeraJDBC__indep_indep.14.10.00.26\\tdgssconfig.jar")
Error in .jfindClass(as.character(driverClass)[1]) : class not found
what's the fix?
 

jjordan 7 comments Joined 03/11
03 Feb 2014

Please ensure that you have the terajdbc4.jar file as well as the tdgssconfig.jar file defined.
 
This step is shown in the article:

  1. drv = JDBC("com.teradata.jdbc.TeraDriver","ClasspathForTeradataJDBCDriverFiles") <enter>

         Example: drv = JDBC("com.teradata.jdbc.TeraDriver","c:\\terajdbc\\terajdbc4.jar;c:\\terajdbc\\tdgssconfig.jar")

Alexander K 2 comments Joined 09/13
25 Aug 2015

Is there any way to execute statements like "SET" and "DATABASE" through JDBC?
After successfully establishing a connection in variable "conn", when I try to specify a statement like

dbGetQuery(conn, "DATABASE myDB;")
or
dbGetQuery(conn, "SET SESSION SEARCHUIFDBPATH = myDB;")
then I get the error:
Error in .valueClassTest(standardGeneric("fetch"), "data.frame", "fetch") : invalid value from generic function ‘fetch’, class “NULL”, expected “data.frame”
Is there any db* function or any other way JDBC might allow one to run statements like the above?
Thanks,
Alexander.

tomnolan 21 comments Joined 01/08
27 Aug 2015

This blog entry by Andreas illustrates how to call JDBC API methods directly.
https://developer.teradata.com/blog/amarek/2013/12/how-to-avoid-duplicate-jdbc-connection-created-by-rjdbc-dbconnect
 
You can use this technique to execute any kind of SQL request, including a SQL request that does not return a result set.

01 Jun 2016

Regarding this article:

- It is three years old.  

- There is a comment stating that TeradataR is no longer supported.   

- The link to TeradataR is broken. 

 

So everything seems to indicate that we should not be using Teradata from an R script.   But I went ahead and gave it a try anyway and it worked.   I did this from Windows 10.

 

My question is:  Can I trust TeradataR for a production deployment? 

 

This is what I did to get things working.

 

1.  As I mentioned above, the link on this page to TeradataR is broken.  So I used a version of teradataR from gitHub:   https://github.com/Teradata/teradataR.

2.  Next I downloaded the JDBC driver.  I used the link shown on this article:  http://downloads.teradata.com/download/connectivity/jdbc-driver.  I placed the driver in c:\temp\terajdbc.

3.  I then went into R Studio and I installed TeradataR by pointing at the downloaded teradataR_1.1.0.tar.gz.

4.  From R Studio I then installed RJDBC from CRAN.

5.  Finally I ran the code below.     

 

library(RJDBC)

library(teradataR)

jdbc_driver = JDBC("com.teradata.jdbc.TeraDriver","C:\\temp\\terajdbc\\terajdbc4.jar;C:\\temp\\terajdbc\\tdgssconfig.jar")

jdbc_connection = dbConnect(jdbc_driver, "jdbc:teradata://MY_SERVER_NAME/LOGMECH=LDAP", "MY_TERADATA_ID", .rs.askForPassword("Enter password:"))

jdbc_data <- dbGetQuery(jdbc_connection, "SELECT firstname FROM customer;")

dbDisconnect(jdbc_connection)

 

So everything looks good.   But I don't want to use teradataR in production if Teradata is not currently supporting it.  Please let me know what Teradata's position is on this.

 

 

 

Carlos -

16 Jun 2016

I just tried this out on Linux (Red Hat 7) and it worked there as well.  For any of you trying this out on Linux, please remember (as it is described earlier in this document) that a colon (not a semi-colon) is required to separate the jar paths.  

 

Windows Example:

jdbc_driver = JDBC("com.teradata.jdbc.TeraDriver","C:\\Temp\\terajdbc\\terajdbc4.jar;C:\\Temp\\terajdbc\\tdgssconfig.jar")

 

Linux Example (colon instead of semicolon)

drv = JDBC("com.teradata.jdbc.TeraDriver","/Temp/terajdbc/terajdbc4.jar:/Temp/terajdbc/tdgssconfig.jar")

 

Carlos -

jjordan 7 comments Joined 03/11
20 Jun 2016

Product Management confirmed that teradataR is no longer supported by Teradata.
 
It is currently available as an open source project on GitHub: https://github.com/Teradata/teradataR
 
Please note that the teradataR open source project is not supported by Teradata, but I understand that some customers are using it.
 
I have posted a new article showing how to use the Teradata JDBC Driver with R, omitting any reference to teradataR.
http://developer.teradata.com/connectivity/articles/how-to-use-the-teradata-jdbc-driver-with-r-0

You must sign in to leave a comment.