Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Hive Connectivity using java

 
Ranch Hand
Posts: 108
  • 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
 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hive should be run as a server
 
syruss kumar
Ranch Hand
Posts: 108
  • 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
  • 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
 
Greenhorn
Posts: 1
  • 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
 
Greenhorn
Posts: 13
  • 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.
 
Thanks tiny ad, for helping me escaped\ the terrible comfort of this chair.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!