Connect Hive Operation instance notes via JDBC Driver

Source: Internet
Author: User
Tags stmt

package com.yuxipacific; import java.sql. Connection ; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class Hive {      public static void main(String[] args) throws Exception {                   Class.forName( "org.apache.hadoop.hive.jdbc.HiveDriver" );                   //String dropSQL= "drop table javabloger" ;          //String createSQL= "create table javabloger (key int, value string)" ;          //String insterSQL= "LOAD DATA LOCAL INPATH ‘/work/hive/examples/files/kv1.txt‘ OVERWRITE INTO TABLE javabloger" ;          //String querySQL= "SELECT a.* FROM javabloger a" ;          String querySQL= "SELECT * FROM pokes" ;                   Connection con = DriverManager.getConnection( "jdbc:hive://192.168.11.124:10000/default" "" "" );          Statement stmt = con.createStatement(); //        stmt.executeQuery(dropSQL); //        stmt.executeQuery(createSQL); //        stmt.executeQuery(insterSQL);          ResultSet res = stmt.executeQuery(querySQL);                   while (res. next ()) {              System. out .println( "Result: key:" +res.getString(1) + "  –>  value:" +res.getString(2));          }      } }

Connect Hive Operation instance notes via JDBC Driver

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.