Unable to integrate rstudio to hive

rstudio
rjdbc
rjava
#1

library(DBI)
library(rJava)
library(RJDBC)
.jaddClassPath("/opt/cloudera/parcels/CDH-5.16.1-1.cdh5.16.1.p0.3/jars/hive-jdbc-1.1.0-cdh5.16.1.jar")
.jaddClassPath("/opt/cloudera/parcels/CDH-5.16.1-1.cdh5.16.1.p0.3/jars/hive-jdbc-1.1.0-cdh5.16.1-standalone.jar")
.jaddClassPath("/opt/cloudera/parcels/CDH-5.16.1-1.cdh5.16.1.p0.3/jars/hive-metastore-1.1.0-cdh5.16.1.jar")
.jaddClassPath("/opt/cloudera/parcels/CDH-5.16.1-1.cdh5.16.1.p0.3/jars/hive_metastore.jar")
.jaddClassPath("/opt/cloudera/parcels/CDH-5.16.1-1.cdh5.16.1.p0.3/jars/hadoop-common-2.6.0-cdh5.16.1.jar")

drv <- JDBC("org.apache.hive.jdbc.HiveDriver","/opt/cloudera/parcels/CDH-5.16.1-1.cdh5.16.1.p0.3/jars/hive-jdbc-1.1.0-cdh5.16.1.jar", identifier.quote=" ")

conn <- dbConnect(drv, "jdbc:hive2://3.14.23.73:10000/mldb;","user", "******")
show_databases <- dbGetQuery(conn,"show databases")

Error:

  1. Error in .jcall(drv@jdrv, "Ljava/sql/Connection;", "connect", as.character(url)[1], :
  2. java.lang.NoClassDefFoundError: Could not initialize class org.apache.hive.service.auth.HiveAuthFactory
0 Likes

#2

Hi, maybe you can consider using ODBC drivers instead of JDBC, they're easier to setup:

0 Likes