Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Integrate R and hive using RJDBC

Integrate R and hive using RJDBC

Explorer

Hi Team,

I am trying to integrate R and hive using RJDBC, when i execute below code getting "Class Not found" exception.

library(DBI)
library(rJava)
library(RJDBC)
hadoop.class.path = list.files(path=c("/usr/hdp/current/hadoop"),pattern="jar", full.names=T);
hive.class.path = list.files(path=c("/usr/hdp/current/hive-client/lib/"),pattern="jar", full.names=T);
hadoop.lib.path = list.files(path=c("/usr/hdp/current/hive-client/lib/"),pattern="jar",full.names=T);
mapred.class.path = list.files(path=c("/usr/hdp/current/hadoop-mapreduce-client/lib/"),pattern="jar",full.names=T);
cp = c(hive.class.path,hadoop.lib.path,mapred.class.path,hadoop.class.path)
.jinit(classpath=cp,parameters="-Djavax.security.auth.useSubjectCredsOnly=false")
.jclassLoader()$setDebug(1L)


drv <- JDBC("org.apache.hive.jdbc.HiveDriver","/usr/hdp/current/hive-client/lib/hive-jdbc.jar",identifier.quote="`")
RJavaClassLoader: added '/usr/hdp/current/hive-client/lib/hive-jdbc.jar' to the URL class path loader
RJavaClassLoader: adding Java archive file '/usr/hdp/current/hive-client/lib/hive-jdbc.jar' to the internal class path
RJavaClassLoader: added '/usr/lib64/RRO-3.2.0/R-3.2.0/lib64/R/library/RJDBC/java/RJDBC.jar' to the URL class path loader
RJavaClassLoader: adding Java archive file '/usr/lib64/RRO-3.2.0/R-3.2.0/lib64/R/library/RJDBC/java/RJDBC.jar' to the internal class path
RJavaClassLoader@3f26f816.findClass(org.apache.hive.jdbc.HiveDriver)
Error in .jfindClass(as.character(driverClass)[1]) : class not found
 
Don't have an account?
Coming from Hortonworks? Activate your account here