0

I am writing Jdbc program to connect with hive database but I am getting error as:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/conf/Configuration at org.apache.hive.jdbc.HiveConnection.createUnderlyingTransport(HiveConnection.java:418) at org.apache.hive.jdbc.HiveConnection.createBinaryTransport(HiveConnection.java:438) at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:225) at org.apache.hive.jdbc.HiveConnection.(HiveConnection.java:182) at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:107) at java.sql.DriverManager.getConnection(DriverManager.java:571) at java.sql.DriverManager.getConnection(DriverManager.java:215) at com.nucsoft.client.HiveJdbc.main(HiveJdbc.java:31)

Binary Nerd
  • 13,872
  • 4
  • 42
  • 44
arya
  • 11
  • 4
  • Check your dependencies/jars...you are missing one of those – Akshay Jul 04 '17 at 07:18
  • I am using hadoop-2.7.3 version so can anybody tell me from where i can download hadoop-core-2.7.3 jar – arya Jul 04 '17 at 07:23
  • The libraries are not present in the classpath. If you are running the program in a machine where hive is already installed, then you can use the command - hive --service jar
    – nJn Jul 04 '17 at 07:32

1 Answers1

0

You're missing the Configuration class. hadoop-core jar was changed to hadoop-common in Hadoop 2. Here's the dependency and a link to download the JAR:

<dependency>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-common</artifactId>
    <version>2.7.3</version>
</dependency>
philantrovert
  • 9,904
  • 3
  • 37
  • 61
  • thanks for the solution but now i am getting error as Exception in thread "main" java.sql.SQLException: Could not open client transport with JDBC Uri: jdbc:hive2://localhost:10000/default: java.net.ConnectException: Connection refused can you send me hive-site.xml file. Which property should i write in hive-site.xml for hive server 2 – arya Jul 04 '17 at 15:29
  • Cloudera's Hive JDBC driver comes with a well-written documentation. Follow it and you should be able to solve this because that is out of scope for your current question. – philantrovert Jul 04 '17 at 15:50
  • And mark this answer as THE answer :) – robermann Jul 12 '17 at 15:55