<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: how to execute hive program or hive jar file in hortonworks in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-execute-hive-program-or-hive-jar-file-in-hortonworks/m-p/100875#M13632</link>
    <description>&lt;P&gt;i already have that  jar file in my hortonworks,i want know how to compile and execute the file on that path  &lt;/P&gt;</description>
    <pubDate>Tue, 29 Dec 2015 12:26:53 GMT</pubDate>
    <dc:creator>hadoopsmi</dc:creator>
    <dc:date>2015-12-29T12:26:53Z</dc:date>
    <item>
      <title>how to execute hive program or hive jar file in hortonworks</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-execute-hive-program-or-hive-jar-file-in-hortonworks/m-p/100873#M13630</link>
      <description>&lt;P&gt;i want execute the below program in hortonworks some one help me&lt;/P&gt;&lt;PRE&gt;import java.sql.SQLException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.DriverManager;

public class HiveJdbcClient {
  private staticString 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);
    }
    Connection con = DriverManager.getConnection("jdbc:hive://localhost:10000/default", "", "");
    Statement stmt = con.createStatement();
    String tableName = "testHiveDriverTable";
    stmt.executeQuery("drop table " + tableName);
    ResultSet res = stmt.executeQuery("create table "+ tableName + " (key int, value string)");
    // show tables
    String sql = "show tables '"+ tableName + "'";
    System.out.println("Running: " + sql);
    res = stmt.executeQuery(sql);
    if(res.next()) {
      System.out.println(res.getString(1));
    }
    // describe table
    sql = "describe " + tableName;
    System.out.println("Running: " + sql);
    res = stmt.executeQuery(sql);
    while (res.next()) {
      System.out.println(res.getString(1) + "\t" + 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 = "/tmp/a.txt";sql = "load data local inpath '" + filepath + "' into table " + tableName;
    System.out.println("Running: "+ sql);
    res = stmt.executeQuery(sql);
    // select * query sql = "select * from " + tableName;
    System.out.println("Running: " + sql);
    res = stmt.executeQuery(sql);
    while (res.next()) {
      System.out.println(String.valueOf(res.getInt(1)) + "\t" + res.getString(2));
    }
    // regular hive query
    sql = "select count(1) from " + tableName;
    System.out.println("Running: " + sql);
    res = stmt.executeQuery(sql);
    while (res.next()) {
      System.out.println(res.getString(1));
    }
  }
}&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Dec 2015 23:33:12 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-execute-hive-program-or-hive-jar-file-in-hortonworks/m-p/100873#M13630</guid>
      <dc:creator>hadoopsmi</dc:creator>
      <dc:date>2015-12-28T23:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to execute hive program or hive jar file in hortonworks</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-execute-hive-program-or-hive-jar-file-in-hortonworks/m-p/100874#M13631</link>
      <description>&lt;P&gt;You would need the following jars in your classpath:&lt;/P&gt;&lt;P&gt;/usr/hdp/current/hive-client/lib/hive-jdbc.jar&lt;/P&gt;&lt;P&gt;/usr/hdp/current/hadoop-client/hadoop-common.jar&lt;/P&gt;&lt;P&gt;/usr/hdp/current/hadoop-client/hadoop-auth.jar&lt;/P&gt;&lt;P&gt;With these in the classpath you can compile and execute your java client.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2015 01:01:41 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-execute-hive-program-or-hive-jar-file-in-hortonworks/m-p/100874#M13631</guid>
      <dc:creator>deepesh1</dc:creator>
      <dc:date>2015-12-29T01:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to execute hive program or hive jar file in hortonworks</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-execute-hive-program-or-hive-jar-file-in-hortonworks/m-p/100875#M13632</link>
      <description>&lt;P&gt;i already have that  jar file in my hortonworks,i want know how to compile and execute the file on that path  &lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2015 12:26:53 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-execute-hive-program-or-hive-jar-file-in-hortonworks/m-p/100875#M13632</guid>
      <dc:creator>hadoopsmi</dc:creator>
      <dc:date>2015-12-29T12:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to execute hive program or hive jar file in hortonworks</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-execute-hive-program-or-hive-jar-file-in-hortonworks/m-p/100876#M13633</link>
      <description>&lt;P&gt;To compile:&lt;/P&gt;&lt;PRE&gt;$JAVA_HOME/bin/java HiveJdbcClient.java&lt;/PRE&gt;&lt;P&gt;To execute:&lt;/P&gt;&lt;PRE&gt;$JAVA_HOME/bin/java -cp .:/usr/hdp/current/hive-client/lib/hive-jdbc.jar:/usr/hdp/current/hadoop-client/hadoop-common.jar:/usr/hdp/current/hadoop-client/hadoop-auth.jar HiveJdbcClient&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Dec 2015 14:09:49 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-execute-hive-program-or-hive-jar-file-in-hortonworks/m-p/100876#M13633</guid>
      <dc:creator>deepesh1</dc:creator>
      <dc:date>2015-12-29T14:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to execute hive program or hive jar file in hortonworks</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-execute-hive-program-or-hive-jar-file-in-hortonworks/m-p/100877#M13634</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/838/hadoopsmi.html" nodeid="838"&gt;@sivasaravanakumar k&lt;/A&gt; has this been resolved? Can you post your solution or accept the best answer?&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2016 10:42:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-execute-hive-program-or-hive-jar-file-in-hortonworks/m-p/100877#M13634</guid>
      <dc:creator>aervits</dc:creator>
      <dc:date>2016-02-03T10:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to execute hive program or hive jar file in hortonworks</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-execute-hive-program-or-hive-jar-file-in-hortonworks/m-p/100878#M13635</link>
      <description>&lt;P&gt;@&lt;A href="https://community.hortonworks.com/users/838/hadoopsmi.html"&gt;sivasaravanakumar k&lt;/A&gt; If you are using any IDE to develop program like Eclipse then you can Add all required JAR file to program path and then build JAR using Eclipse. (http://tutoringcenter.cs.usfca.edu/resources/adding-user-libraries-in-eclipse.html)&lt;/P&gt;&lt;P&gt;If you want to run your program on remote job where these jar might not be on classpath then build FAT/Executable jar using Eclipse. FAT JAR will ensure that all the required dependency is packaged with the program. (http://stackoverflow.com/questions/502960/eclipse-how-to-build-an-executable-jar-with-external-jar)&lt;/P&gt;&lt;P&gt;You can also use build-tool like Maven to handle dependency for you.&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 19:35:40 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/how-to-execute-hive-program-or-hive-jar-file-in-hortonworks/m-p/100878#M13635</guid>
      <dc:creator>pradeep_bhadani</dc:creator>
      <dc:date>2016-05-18T19:35:40Z</dc:date>
    </item>
  </channel>
</rss>

