Error related to 'rJava' and 'RJDBC'


#1

Hello RStudio Community!

I have installed the 'rJava' and 'RJDBC' packages in order to connect to a Vertica database. While I had some issues getting the packages to load, I have resolved them.

However, in an attempt to actually execute one of their functions, I am facing a new error. The code that I am running is:

drv <- JDBC(
  driverClass = "com.vertica.jdbc.Driver",
  classPath = Sys.getenv("classPath")

The error that I am receiving is:

Error in .jfindClass(as.character(driverClass)[1]) : class not found

Could someone please advise? Thank you!


#2

It's been a while since I have had the "pleasure" of using rJava. It sounds like the "com.vertica.jdbc.Driver" class is not on your class path. If you can find the .jar that has that class in it and then include that .jar file in the class path, I think that should resolve your issue.


#3

Hey!

Apologies for the delayed response.

Thanks for your answer. I think I found the file, but not sure on what the steps are to "include" it into the .jar file. Could you please advise?


#4

Sorry for the delay in responding to this. If you have found the .jar file that you need, you can include it on your classpath with:

rJava::.jaddClassPath("/path/to/my.jar")

# retrieve the current classPath (where Java will look for jar files)
rJava::.jclassPath()