zoukankan      html  css  js  c++  java
  • JAVA采用远程连接Hive

    1.启动hive
    2.启动hive远程服务端口 ---- bin/hive --service hiveserver 50031 &
    3.在eclipse创建一个hadoop项目,导入 hadoop.jar,hive等相关的jar包至项目
    3.一个测试代码
    HiveTestCase.java
     
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.Statement;
    public class HiveTestCase {
                 public static void main(String[] args) throws  Exception {        
                     Class.forName("org.apache.hadoop.hive.jdbc.HiveDriver");        
                     String createSQL="create table javabloger3 (key int, value string)"; 
                     Connection con = DriverManager.getConnection("jdbc:hive://127.0.0.1:50031/default", "", "");
                     Statement stmt = con.createStatement();
                     stmt.executeQuery(createSQL);
                     System.out.println("ok");
                 }
    }
  • 相关阅读:
    Window 中的自带方法Base64
    React_Class1
    npm 常用操作
    React__生命周期
    axios 简单方法个人理解
    JavaScript_Window对象
    常见的搜索引擎技巧
    JS_String常见问题Demo
    java调用C++代码
    java虚拟机指令dup的理解
  • 原文地址:https://www.cnblogs.com/bobsoft/p/2714479.html
Copyright © 2011-2022 走看看