{"id":3014,"date":"2013-06-10T08:47:55","date_gmt":"2013-06-10T13:47:55","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=3014"},"modified":"2013-06-10T08:47:55","modified_gmt":"2013-06-10T13:47:55","slug":"cloudera-impala-simple-command-line-test","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2013\/06\/10\/cloudera-impala-simple-command-line-test\/","title":{"rendered":"Cloudera Impala simple command line test"},"content":{"rendered":"<p>I am a big believer in simple command line examples.  Connecting the dots is so much easier when you do this.<\/p>\n<p>There will be much more on this, but this should get you started.<\/p>\n<p>CLASSPATH is shown below.  The absolute locations will differ according to where you place your jar files.<\/p>\n<pre lang=\"text\">\r\n[root@util01 test]# env | grep CLASS | awk '{split($1,t,\":\");while (++i <= length(t)) {print t[i]}}'\r\nCLASSPATH=.\r\n\/usr\/share\/tomcat5\/common\/lib\/hive_contrib.jar\r\n\/usr\/share\/tomcat5\/common\/lib\/hive-jdbc-0.10.0-cdh4.2.0.jar\r\n\/usr\/share\/tomcat5\/common\/lib\/hive-metastore-0.10.0-cdh4.2.0.jar\r\n\/usr\/share\/tomcat5\/common\/lib\/hive-service-0.10.0-cdh4.2.0.jar\r\n\/usr\/share\/tomcat5\/common\/lib\/libthrift-0.9.0.jar\r\n\/usr\/share\/tomcat5\/common\/lib\/slf4j-api-1.6.4.jar\r\n\/usr\/share\/tomcat5\/common\/lib\/commons-logging-1.0.4.jar\r\n[root@util01 test]#\r\n<\/pre>\n<p>Java code below...<\/p>\n<pre lang=\"java\" line=\"1\">\r\nimport java.sql.*;\r\n\r\npublic class hive {\r\n  public static void main (String args[]) {\r\n    try {\r\n      Class.forName(\"org.apache.hive.jdbc.HiveDriver\");\r\n      Connection con = DriverManager.getConnection(\"jdbc:hive2:\/\/192.168.3.50:21050\/;auth=noSasl\");\r\n      Statement stmt = con.createStatement();\r\n      ResultSet res = stmt.executeQuery(\"select * from x\");\r\n      while (res.next()) {\r\n        System.out.println(res.getInt(1) + \"<br>\");\r\n      }\r\n      stmt.close();\r\n      con.close();\r\n    }\r\n    catch (Exception e) {\r\n      e.printStackTrace();\r\n      System.out.println(e.getMessage());\r\n    }\r\n  }\r\n}\r\n<\/pre>\n<p>...and output of the run...<\/p>\n<pre lang=\"text\">\r\n[root@util01 test]# java hive\r\nSLF4J: Failed to load class \"org.slf4j.impl.StaticLoggerBinder\".\r\nSLF4J: Defaulting to no-operation (NOP) logger implementation\r\nSLF4J: See http:\/\/www.slf4j.org\/codes.html#StaticLoggerBinder for further details.\r\n1<br>\r\n2<br>\r\n3<br>\r\n4<br>\r\n5<br>\r\n6<br>\r\n\r\n<snip>\r\n\r\n97<br>\r\n98<br>\r\n99<br>\r\n100<br>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I am a big believer in simple command line examples. Connecting the dots is so much easier when you do this. There will be much more on this, but this should get you started. CLASSPATH is shown below. The absolute&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2013\/06\/10\/cloudera-impala-simple-command-line-test\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[19,24,21,25],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/3014"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=3014"}],"version-history":[{"count":10,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/3014\/revisions"}],"predecessor-version":[{"id":3088,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/3014\/revisions\/3088"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=3014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=3014"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=3014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}