Two Laptop Bag*
The moose likes Hadoop and the fly likes Hive Connectivity using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Hadoop
Bookmark "Hive Connectivity using java" Watch "Hive Connectivity using java" New topic
Author

Hive Connectivity using java

syruss kumar
Ranch Hand

Joined: Jul 23, 2009
Posts: 93
Hi All,

Im trying to query hive database using java JDBC.I followed the same steps which mentioned in the apache wiki https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients,
if i try to execute the code it throws me class not found exception.

Even i have included the following jars in my classpath.

hive-0.11.0.jar
hive-jdbc-0.9.0-cdh4.1.2.jar
hive-shims-0.10.0-cdh4.5.0.jar
libfb303.jar
libthrift.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.6.1.jar

hive-shims-0.10.0-cdh4.5.0.jar has org/apache/hadoop/hive/shims/ShimLoader class in it.





Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/hive/shims/ShimLoader
at org.apache.hive.service.auth.KerberosSaslHelper.getKerberosTransport(KerberosSaslHelper.java:67)
at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:137)
at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:96)
at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:104)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at com.walmart.ckp.qa.sourcing.App.getConnection(Unknown Source)
at com.walmart.ckp.qa.sourcing.App.main(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.hive.shims.ShimLoader
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)



Please suggest me how to solve this

Thanks in advance


All search starts with beginner's luck and all search ends with victor's severly tested.
Rajesh Nagaraju
Ranch Hand

Joined: Nov 27, 2003
Posts: 61
hive should be run as a server
syruss kumar
Ranch Hand

Joined: Jul 23, 2009
Posts: 93
Hi Rajesh,

can you please elaborate this ?


Thanks a lot for your response
Rajesh Nagaraju
Ranch Hand

Joined: Nov 27, 2003
Posts: 61
Sorry I had not checked for some time

hive should be run as a server -- means that when we run it as a server, it runs the thrift service which enables us to connect through Java
robbie feng
Greenhorn

Joined: Jul 29, 2014
Posts: 1
I think you need some hadoop common libs for hive is base on hadoop
Rajit kumar
Greenhorn

Joined: Mar 04, 2012
Posts: 11
It works as one of the server service and need to have libs as stated above.If you use other distributions for hadoop installation the hive client are configured with that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hive Connectivity using java