<?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: please help compile in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/please-help-compile/m-p/231202#M193046</link>
    <description>&lt;P&gt;thanks !&lt;/P&gt;&lt;P&gt;I did the first change you asked and it compiled but now its failing when I run it . I changed "hive" to "hive2" but getting the error :&lt;/P&gt;&lt;PRE&gt;[hdfs@hadoop1 ~]$ grep hive2 HiveAlterRenameTo.java
      Connection con = DriverManager.getConnection("jdbc:hive2://localhost:10000/default", "", "");
[hdfs@hadoop1 ~

[hdfs@hadoop1 ~]$ java -cp .:$HADOOP_CLASSPATH:/usr/hdp/2.5.3.0-37/hive2/lib/*  HiveAlterRenameTo
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
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.&amp;lt;init&amp;gt;(HiveConnection.java:182)
        at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:107)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at HiveAlterRenameTo.main(HiveAlterRenameTo.java:16)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.conf.Configuration
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 8 more

&lt;/PRE&gt;</description>
    <pubDate>Thu, 06 Jul 2017 01:11:39 GMT</pubDate>
    <dc:creator>aliyesami</dc:creator>
    <dc:date>2017-07-06T01:11:39Z</dc:date>
    <item>
      <title>please help compile</title>
      <link>https://community.cloudera.com/t5/Support-Questions/please-help-compile/m-p/231200#M193044</link>
      <description>&lt;P&gt;I posted this question before but got no response . &lt;/P&gt;&lt;P&gt;I am unable to compile this java code even though I am specifiying the right jars . please advise &lt;/P&gt;&lt;PRE&gt;[hdfs@hadoop1 ~]$ HADOOP_CLASSPATH=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-0.b15.el6_8.x86_64/lib/tools.jar
[hdfs@hadoop1 ~]$ export HADOOP_CLASSPATH
[hdfs@hadoop1 ~]$ javac -cp $HADOOP_CLASSPATH:/usr/hdp/2.5.3.0-37/hive2/lib/*  HiveAlterRenameTo.java
HiveAlterRenameTo.java:13: error: unreported exception ClassNotFoundException; must be caught or declared to be thrown
      Class.forName(driverName);
                   ^
1 error
[hdfs@hadoop1 ~]$ more HiveAlterRenameTo.java
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.DriverManager;
public class HiveAlterRenameTo {
   private static String driverName = "org.apache.hive.jdbc.HiveDriver";
   public static void main(String[] args) throws SQLException {
      // Register driver and create driver instance
      Class.forName(driverName);
      // get connection
      Connection con = DriverManager.getConnection("jdbc:hive://localhost:10000/default", "", "");
      // create statement
      Statement stmt = con.createStatement();
      // execute statement
      stmt.executeQuery("ALTER TABLE PA_LANE_TXN_ORC RENAME TO PA_LANE_TXN;");
      System.out.println("Table Renamed Successfully");
      con.close();
   }
}


&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Jul 2017 01:01:42 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/please-help-compile/m-p/231200#M193044</guid>
      <dc:creator>aliyesami</dc:creator>
      <dc:date>2017-07-06T01:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: please help compile</title>
      <link>https://community.cloudera.com/t5/Support-Questions/please-help-compile/m-p/231201#M193045</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/10115/sahmad43.html" nodeid="10115"&gt;@Sami Ahmad&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Please replace the :&lt;/P&gt;&lt;PRE&gt; public static void main(String[] args) throws SQLException {&lt;/PRE&gt;&lt;P&gt;With the following:&lt;/P&gt;&lt;PRE&gt; public static void main(String[] args) throws Exception {&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;OR &lt;/STRONG&gt;as an alternative approach either use "try{  }  catch(ClassNotFoundException cnef)".&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;OR&lt;/STRONG&gt; try &lt;/P&gt;&lt;PRE&gt; public static void main(String[] args) throws SQLException, ClassNotFoundException {&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 01:04:42 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/please-help-compile/m-p/231201#M193045</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2017-07-06T01:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: please help compile</title>
      <link>https://community.cloudera.com/t5/Support-Questions/please-help-compile/m-p/231202#M193046</link>
      <description>&lt;P&gt;thanks !&lt;/P&gt;&lt;P&gt;I did the first change you asked and it compiled but now its failing when I run it . I changed "hive" to "hive2" but getting the error :&lt;/P&gt;&lt;PRE&gt;[hdfs@hadoop1 ~]$ grep hive2 HiveAlterRenameTo.java
      Connection con = DriverManager.getConnection("jdbc:hive2://localhost:10000/default", "", "");
[hdfs@hadoop1 ~

[hdfs@hadoop1 ~]$ java -cp .:$HADOOP_CLASSPATH:/usr/hdp/2.5.3.0-37/hive2/lib/*  HiveAlterRenameTo
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
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.&amp;lt;init&amp;gt;(HiveConnection.java:182)
        at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:107)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at HiveAlterRenameTo.main(HiveAlterRenameTo.java:16)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.conf.Configuration
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 8 more

&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Jul 2017 01:11:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/please-help-compile/m-p/231202#M193046</guid>
      <dc:creator>aliyesami</dc:creator>
      <dc:date>2017-07-06T01:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: please help compile</title>
      <link>https://community.cloudera.com/t5/Support-Questions/please-help-compile/m-p/231203#M193047</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/10115/sahmad43.html" nodeid="10115"&gt;@Sami Ahmad
&lt;/A&gt;&lt;/P&gt;&lt;P&gt;You have not set the CLASSPATH properly to inclide the required HIve and Hadoop JARs to it. &lt;/P&gt;&lt;P&gt;If you really want to run a simple hive client code then please refer to the following Example where i developed a very simple Java Based Hive Client using Maven:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/jaysensharma/MiddlewareMagicDemos/tree/master/HDP_Ambari/Hive/HiveJavaClient"&gt;https://github.com/jaysensharma/MiddlewareMagicDemos/tree/master/HDP_Ambari/Hive/HiveJavaClient&lt;/A&gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/10115/sahmad43.html" nodeid="10115"&gt;&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 01:25:25 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/please-help-compile/m-p/231203#M193047</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2017-07-06T01:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: please help compile</title>
      <link>https://community.cloudera.com/t5/Support-Questions/please-help-compile/m-p/231204#M193048</link>
      <description>&lt;P&gt;ok I tried including all the hive2 and hadoop jar directories and it fixed the issue but now I am getting connection refused , please advise &lt;/P&gt;&lt;PRE&gt;$ HADOOP_CLASSPATH=/usr/hdp/2.5.3.0-37/hive2/lib/*:/usr/hdp/2.5.3.0-37/hadoop/*:/usr/hdp/2.5.3.0-37/hadoop-mapreduce/*
$ export HADOOP_CLASSPATH
[hdfs@hadoop1 ~]$ java -cp .:$HADOOP_CLASSPATH:/usr/hdp/2.5.3.0-37/*  HiveAlterRenameTo
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
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 (Connection refused)
        at org.apache.hive.jdbc.HiveConnection.&amp;lt;init&amp;gt;(HiveConnection.java:209)


&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Jul 2017 01:51:02 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/please-help-compile/m-p/231204#M193048</guid>
      <dc:creator>aliyesami</dc:creator>
      <dc:date>2017-07-06T01:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: please help compile</title>
      <link>https://community.cloudera.com/t5/Support-Questions/please-help-compile/m-p/231205#M193049</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/10115/sahmad43.html" nodeid="10115"&gt;@Sami Ahmad&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Change the line in your code that you posted Initially.&lt;/P&gt;&lt;PRE&gt;DriverManager.getConnection("jdbc:hive://localhost:10000/default", "", "");&lt;/PRE&gt;&lt;P&gt;
With the following line in your code :  (notice&lt;STRONG&gt; "jdbc:hive"&lt;/STRONG&gt;  is replaced with&lt;STRONG&gt; "jdbc:hive2"&lt;/STRONG&gt;)&lt;/P&gt;&lt;PRE&gt;DriverManager.getConnection("jdbc:hive2://localhost:10000/default", "", "");&lt;/PRE&gt;&lt;P&gt;
&lt;STRONG&gt;The  compile and run it as following:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;export CLASSPATH=/usr/hdp/current/hive-client/lib/*:/usr/hdp/current/hive-client/jdbc/*:.:
javac HiveAlterRenameTo.java 
java HiveAlterRenameTo&lt;/PRE&gt;&lt;P&gt;


If you want specific JAR names then copy the jars present in the above two directories and then manually add them in your classpath.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 01:55:08 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/please-help-compile/m-p/231205#M193049</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2017-07-06T01:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: please help compile</title>
      <link>https://community.cloudera.com/t5/Support-Questions/please-help-compile/m-p/231206#M193050</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/10115/sahmad43.html" nodeid="10115"&gt;@Sami Ahmad
&lt;/A&gt;&lt;/P&gt;&lt;P&gt;For different issues , Better to open separate HCC thread. That way we can manage the threads properly and users can quickly find one issue one resolution.
&lt;A rel="user" href="https://community.cloudera.com/users/10115/sahmad43.html" nodeid="10115"&gt;&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 01:56:28 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/please-help-compile/m-p/231206#M193050</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2017-07-06T01:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: please help compile</title>
      <link>https://community.cloudera.com/t5/Support-Questions/please-help-compile/m-p/231207#M193051</link>
      <description>&lt;P&gt;still getting connection refused ,  I also tried port 10001  but same result.
my hive2 server is running on hadoop2 so I changed the line as below .   I tried both ports 10000 and 10001 with same results.&lt;/P&gt;&lt;PRE&gt; // get connection
      Connection con = DriverManager.getConnection("jdbc:hive2://hadoop2:10001/default", "", "");


&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Jul 2017 02:05:14 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/please-help-compile/m-p/231207#M193051</guid>
      <dc:creator>aliyesami</dc:creator>
      <dc:date>2017-07-06T02:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: please help compile</title>
      <link>https://community.cloudera.com/t5/Support-Questions/please-help-compile/m-p/231208#M193052</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/10115/sahmad43.html" nodeid="10115"&gt;@Sami Ahmad
&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Your Compilation Issue is resolved. For which the thread was opened.&lt;/P&gt;&lt;P&gt;Regarding Connection refused, the troubleshooting is completely different. Please open separate HCC thread.&lt;/P&gt;&lt;P&gt;And in Parallel check if the 10000 port is opened by the hive process on the mentioned host "&lt;STRONG&gt;localhost&lt;/STRONG&gt;" or not?  Or check the &lt;STRONG&gt;hostname&lt;/STRONG&gt; is pointing to correct hive instance? &lt;/P&gt;&lt;PRE&gt;# netstat -tnlpa | grep 10000&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;Also check if there is any firewall issue in accessing the hive 10000 port if hive is running on remote host?&lt;/P&gt;&lt;PRE&gt;# telnet  localhost  1000
# telnet  $HIVE_HOSTNAME  10000&lt;/PRE&gt;&lt;P&gt;
&lt;A rel="user" href="https://community.cloudera.com/users/10115/sahmad43.html" nodeid="10115"&gt;&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 02:07:09 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/please-help-compile/m-p/231208#M193052</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2017-07-06T02:07:09Z</dc:date>
    </item>
  </channel>
</rss>

