I have been trying to use RJDBC package to connect R(on local machine) with Hive(server), and am seeing errors:

Error in .jcall(drv@jdrv, "Ljava/sql/Connection;", "connect", as.character(url)[1], : java.sql.SQLException: org.apache.thrift.TApplicationException: Invalid method name: 'execute'

I directly copied the jars that's running on the server to my local machine, which then shouldn't be the problem with the driver versions. I also tried to use earlier versions of RJDBC package, but it didn't work, neither.

I would really appreciate any ideas/suggestions.

My script:

#

hive_connection <- function( hostname, port, lib_dir, hive_jars){ library(RJDBC) library(DBI) library(rJava) library(Rserve)

# lib_dir: directory containing the jars & drivers hive_class_path <- file.path( lib_dir, hive_jars )

drv <- JDBC( 'org.apache.hadoop.hive.jdbc.HiveDriver', classPath= hive_class_path, "`" ) server <- sprintf( 'jdbc:hive://%s:%s', hostname, port )

return ( dbConnect( drv, server, 'hive','hive') ) }

conn <- hive_connection('hostname',9083,'lib_dir', list.files('lib_dir'))

3

There are 3 answers

0
user3739375 On

I resolved the same issue by following two steps -

Change 1:

drv <- JDBC( 'org.apache.hive.jdbc.HiveDriver', classPath= hive_class_path, "`" ) 

The change is in the driver, notice I took out .hadoop

Change 2:

server <- sprintf( 'jdbc:hive2://%s:%s', hostname, port )

I added "2" in the url for connection, to connect to hiveServer2.

I got the detailed explanation by reading this - http://jayunit100.blogspot.com/2013/12/the-anatomy-of-jdbc-connection-in-hive.html

0
abhay On

This is related to driver and port, i was facing same error while connecting hive with jdbc driver. finally i find out right driver and hive service with port. it worked fine.

0
on_the_shores_of_linux_sea On

Try
drv <- JDBC( 'org.apache.hadoop.hive.jdbc.HiveDriver',c(hive_class_path ,pattern="jar$" ,full.names=T) )