Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Error while connecting Hive using JDBC in R script

avatar
New Contributor

Hi

I have an R script that tries to connect to hive using JDBC to pull tables from the hive and perform some processing on the data.

However I'm getting an error at the connection part and am not really sure how to resolve this. Tried different sources on net but couldn't find an answer.

Below is my R code where the error appears and also the error seen on the screen.

cp = c(paste0(BASE_PATH, JAR_DIRECTORY, HADOOP_COMMON_JAR), paste0(BASE_PATH, JAR_DIRECTORY, HIVE_JDBC_JAR))

.jinit(classpath=cp)

drv <- JDBC("org.apache.hive.jdbc.HiveDriver", paste0(BASE_PATH, JAR_DIRECTORY, HIVE_JDBC_JAR), identifier.quote="`")

conn <- dbConnect(drv, "jdbc:hive2://10.0.1.10:10000") //Error is here

Error:

Error in .jcall(drv@jdrv, "Ljava/sql/Connection;", "connect", as.character(url)[1], :

java.sql.SQLException: Could not open client transport with JDBC Uri: jdbc:hive2://xx.x.x.x:10000: java.net.ConnectException: Connection refused (Connection refused)

Calls: dbConnect -> dbConnect -> .local -> .jcall -> .jcheck -> .

Call Execution halted

Any help would be appreciated and I'm happy to provide more insights if required

Thanks

1 ACCEPTED SOLUTION

avatar
Master Mentor
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login
2 REPLIES 2

avatar
Master Mentor
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login

avatar
New Contributor

@Jay Kumar SenSharma. Thanks, the connection to 10000 was refused when I did telnet. Also i don't see anything running on that port when I did netstat.

Apparently, I didn't know that hiveserver2 must be started explicitly and hence was the error.

Do you know what is the property that needs to added to hive-site.xml inorder for me to access the web UI?

Nevertheless, thank you very much. You've helped me great.