title: ClassNotFoundException while connecting to Hive Remotely using Jdbc on Hortonworks
body: <p>I am facing this exception while connecting to beeline, hive2 version 1.2.1000.2.5.0.0, I have added hive-jdbc.jar file into classpath on my Windows 10 machine.</p>
  
  <p><strong>Exception:</strong></p>
  
  <pre><code>java.lang.ClassNotFoundException: org.apache.hadoop.hive.jdbc.HiveDriver
          at java.net.URLClassLoader.findClass(Unknown Source)
          at java.lang.ClassLoader.loadClass(Unknown Source)
          at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
          at java.lang.ClassLoader.loadClass(Unknown Source)
          at java.lang.Class.forName0(Native Method)
          at java.lang.Class.forName(Unknown Source)
          at HiveJdbcClient.main(HiveJdbcClient.java:17)
  </code></pre>
  
  <p><strong>HiveJdbcClient.java</strong></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 = "org.apache.hadoop.hive.jdbc.HiveDriver";
  
    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);
      }
      //replace "hive" here with the name of the user the queries should run as
      Connection con = DriverManager.getConnection("jdbc:hive://localhost:10003/default", "", "");
      Statement stmt = con.createStatement();
      String tableName = "testHiveDriverTable";
      stmt.execute("drop table if exists " + tableName);
      stmt.execute("create table " + tableName + " (key int, value string)");
      // show tables
      String sql = "show tables '" + tableName + "'";
      System.out.println("Running: " + sql);
      ResultSet res = stmt.executeQuery(sql);
      if (res.next()) {
        System.out.println(res.getString(1));
      }
    }
  }
  </code></pre>
  
  <ol>
  <li>I am not sure what other jars I need to add here?</li>
  <li>These jar files change based on the version of Hive?</li>
  <li>Does Cloudera and Hortonworks etc have different jar files, please visit this <a href="https://mvnrepository.com/artifact/org.apache.hive/hive-jdbc" rel="nofollow noreferrer">page</a>, this is so confusing.</li>
  <li>Why it's so complicated to connect to Hive, I have my hive on Hortonworks, which is <a href="http://142.56.78.174:10003/default" rel="nofollow noreferrer">http://142.56.78.174:10003/default</a>, and I have added hive-jdbc jar files to the classpath and I have my java class below. Isn't this enough?</li>
  <li>Please let me know what I am really missing.</li>
  </ol>
  
  <p>Thanks for the answer, I have already tried this,</p>
  
  <pre><code>private static String driverName = "org.apache.hive.jdbc.HiveDriver";
  </code></pre>
  
  <p>Thanks in advance!!</p>