title: unable to fetch data from hive through java code in eclipse
body: <p>i am using Ubuntu 14.04, hadoop-1.2.1(<a href="http://www.michael-noll.com/tutorials/running-hadoop-on-ubuntu-linux-single-node-cluster/" rel="nofollow noreferrer">Single node</a>), hive-1.1.0(<a href="http://www.rohitmenon.com/index.php/how-to-install-apache-hive/" rel="nofollow noreferrer">Stable 1.1.0</a>), eclipse IDE</p>
  <p>i have created a java project and imported all the external jar files in</p>
  <blockquote>
  <p>/usr/local/hive/lib/</p>
  <p>/usr/local/hadoop/hadoop-core-1.2.1.jar</p>
  </blockquote>
  <p>my java code looks like:</p>
  <pre><code>import java.sql.SQLException;
  import java.sql.Connection;
  import java.sql.ResultSet;
  import java.sql.Statement;
  import java.sql.DriverManager;
   
  public class HiveJdbcClient {
    private static String driverName = &quot;org.apache.hadoop.hive.jdbc.HiveDriver&quot;;
   
    public static void main(String[] args) throws SQLException {
      try {
        Class.forName(driverName);
      } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        System.exit(1);
      }
      Connection con = DriverManager.getConnection(&quot;jdbc:hive://localhost:10000/default&quot;, &quot;&quot;, &quot;&quot;);
      Statement stmt = con.createStatement();
      String tableName = &quot;testHiveDriverTable&quot;;
      stmt.executeQuery(&quot;drop table &quot; + tableName);
      ResultSet res = stmt.executeQuery(&quot;create table &quot; + tableName + &quot; (key int, value string)&quot;);
      // show tables
      String sql = &quot;show tables '&quot; + tableName + &quot;'&quot;;
      System.out.println(&quot;Running: &quot; + sql);
      res = stmt.executeQuery(sql);
      if (res.next()) {
        System.out.println(res.getString(1));
      }
      // describe table
      sql = &quot;describe &quot; + tableName;
      System.out.println(&quot;Running: &quot; + sql);
      res = stmt.executeQuery(sql);
      while (res.next()) {
        System.out.println(res.getString(1) + &quot;\t&quot; + res.getString(2));
      }
   
      // load data into table
      // NOTE: filepath has to be local to the hive server
      // NOTE: /tmp/a.txt is a ctrl-A separated file with two fields per line
      String filepath = &quot;/tmp/a.txt&quot;;
      sql = &quot;load data local inpath '&quot; + filepath + &quot;' into table &quot; + tableName;
      System.out.println(&quot;Running: &quot; + sql);
      res = stmt.executeQuery(sql);
   
      // select * query
      sql = &quot;select * from &quot; + tableName;
      System.out.println(&quot;Running: &quot; + sql);
      res = stmt.executeQuery(sql);
      while (res.next()) {
        System.out.println(String.valueOf(res.getInt(1)) + &quot;\t&quot; + res.getString(2));
      }
   
      // regular hive query
      sql = &quot;select count(1) from &quot; + tableName;
      System.out.println(&quot;Running: &quot; + sql);
      res = stmt.executeQuery(sql);
      while (res.next()) {
        System.out.println(res.getString(1));
      }
    }
  }
  </code></pre>
  <p>on running this program in eclipse i am getting this error:</p>
  <blockquote>
  <p>java.lang.ClassNotFoundException:
  org.apache.hadoop.hive.jdbc.HiveDriver    at
  java.net.URLClassLoader$1.run(URLClassLoader.java:366)    at
  java.net.URLClassLoader$1.run(URLClassLoader.java:355)    at
  java.security.AccessController.doPrivileged(Native Method)    at
  java.net.URLClassLoader.findClass(URLClassLoader.java:354)    at
  java.lang.ClassLoader.loadClass(ClassLoader.java:425)     at
  sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)     at
  java.lang.ClassLoader.loadClass(ClassLoader.java:358)     at
  java.lang.Class.forName0(Native Method)   at
  java.lang.Class.forName(Class.java:191)   at
  hive_demo.HiveJdbcClient.main(HiveJdbcClient.java:15)</p>
  </blockquote>
  <p>how to load jdbc driver for hive?</p>