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'))
I resolved the same issue by following two steps -
Change 1:
The change is in the driver, notice I took out .hadoop
Change 2:
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