Connecting from R via RJDBC and terajdbc4.jar fails

Connectivity

Connecting from R via RJDBC and terajdbc4.jar fails

My company is running an R-Studio Server Pro on a Red Hat Linix 6 platform (64bit) and a Teradata 14 RDBMS. When trying to connect via RJDBC, I get an error that seems to be well known in the forums, but the standard recipes for resolving the issues don't help. Here is how I connect to the Teradata DB:

require(RJDBC)
.jaddClassPath("<path>/terajdbc4.jar")
.jaddClassPath("<path>/tdgssconfig.jar")
require(teradataR)

tdConnect("jdbc:teradata://<DSN>/CHARSET=UTF8,TMODE=TERA,SESSIONS=1","<user>","<pwd>","<table>","jdbc")

drv = JDBC("com.teradata.jdbc.TeraDriver", classPath = "<path>/terajdbc4.jar:<path>/tdgssconfig.jar", identifier.quote = "'")

con = dbConnect(drv=drv,"jdbc:teradata://<DSN>/CHARSET=UTF8,TMODE=TERA,SESSIONS=1", "<user>", "<pwd")

ret = dbGetQuery(con, "sel * from <table>")

The tdConnect results in an error message: Error in .jfindClass(as.character(driverClass)[1]) : class not found

whereas the dbConnect is a bit more verbose:

Error in .jcall(drv@jdrv, "Ljava/sql/Connection;", "connect", as.character(url)[1], :

  java.lang.NoClassDefFoundError: com.teradata.tdgss.jtdgss.TdgssManager

I have searched the forums, and found several posts on such an error (e.g. https://forums.teradata.com/forum/analytics/connecting-to-teradata-in-r-via-the-teradatar-package), but they all relate to the standard fault that the tdgssconfig.jar is missing from the classpath.

As you can see, this is not my case. The jars are in the proper place, and the Java class TdgssManager is present in the terajdbc4.jar. The R-function .classPath() also list them properly.

Some background information:

  • I tried all versions of the terajdbc4, and the most recent one is what I'm currently using: TeraJDBC__indep_indep.15.10.00.07
  • We have quite an old Java version (1.5) installed on our server, but according to the documentation of terajdbc4, that should be fine
  • I have downloaded the most recent versions of rJava, DBI, teradataR, and RJDBC  (0.9.7, 0.3.1, 1.0.1, and 0.2.5, respectively)
  • The same code works nicely, when I'm running it on my Windows 7 32 bit company laptop

Can you please give me a hint what still could be wrong?

3 REPLIES
Senior Supporter

Re: Connecting from R via RJDBC and terajdbc4.jar fails

Hi Uwe,

can you try to run the two classpath statements two times. I get sometimes the missing classpath message also. But usually it disapears after I run the class path statements a second time.

also I am using a different connection for the tdConnect

require(RJDBC)

.jaddClassPath("<path>/terajdbc4.jar")
.jaddClassPath("<path>/tdgssconfig.jar")

.jaddClassPath("<path>/terajdbc4.jar")
.jaddClassPath("<path>/tdgssconfig.jar")

require(teradataR)

tdConnect("system","user","password","sys_calendar","jdbc")

tdf <- td.data.frame("calendar")
my.stats <- td.stats(tdf,"year_of_calendar", c("cnt","min","max","mean"))
my.stats

the system is the dsn name found in /etc/hosts not the full jdbc connection string.

I tested this with teradata studio and Teradata R15.0

I don't have R studio server available...

Just to revalidate - the classpath is refering the server path to the jdbc driver, not the local client path. correct?

Kind regards

       Ulrich

Re: Connecting from R via RJDBC and terajdbc4.jar fails

I'm having the exact same problem, and adding the .jaddClassPath's twice does not help.

I'm using RJDBC 0.2-5, Teradata driver 15, and Java 1.6 on Ubuntu linux.

I do not want to use teradataR, as it is no longer supported.

Thanks

Senior Supporter

Re: Connecting from R via RJDBC and terajdbc4.jar fails

can you share your code you are using?