File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hive Connectivity using java

 
syruss kumar
Ranch Hand
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rajesh Nagaraju
Ranch Hand
Posts: 63
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hive should be run as a server
 
syruss kumar
Ranch Hand
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rajesh,

can you please elaborate this ?


Thanks a lot for your response
 
Rajesh Nagaraju
Ranch Hand
Posts: 63
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need some hadoop common libs for hive is base on hadoop
 
Rajit kumar
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic