设为首页 加入收藏

TOP

windows安装Hive
2018-12-02 17:27:44 】 浏览:198
Tags:windows 安装 Hive
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sinat_15153911/article/details/81534316

这里写图片描述
1、环境变量设置
HIVE_HOME D:\DesignSoftware\hive\apache-hive-2.1.0-bin
PATH %HIVE_HOME%\bin;

2、hive-site.xml配置

<configuration>

    <!-- WARNING!!! This file is provided for documentation purposes ONLY!     -->
    <!-- WARNING!!! Any changes you make to this file will be ignored by Hive. -->
    <!-- WARNING!!! You must make your changes in hive-site.xml instead.       -->

    <!-- config mysql connection -->
    <property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://127.0.0.1:3306/db_hivecharacterEncoding=UTF8&amp;useSSL=false&amp;createDatabaseIfNotExist=true</value>
        <description>JDBC connect string for a JDBC metastore</description>
    </property>

    <property>
        <name>javax.jdo.option.ConnectionDriverName</name>
        <value>com.mysql.jdbc.Driver</value>
        <description>Driver class name for a JDBC metastore</description>
    </property>

    <property>
        <name>javax.jdo.option.ConnectionUserName</name>
        <value>root</value>
        <description>username to use against metastore database</description>
    </property>

    <property>
        <name>javax.jdo.option.ConnectionPassword</name>
        <value>934247746</value>
        <description>password to use against metastore database</description>
    </property>
    <property>
        <name>hive.metastore.schema.verification</name>
        <value>false</value>
    </property>



    <property>
        <name>javax.jdo.option.DetachAllOnCommit</name>
        <value>true</value>
        <description>detaches all objects from session so that they can be used after transaction is committed</description>
    </property>

    <property>
        <name>javax.jdo.option.NonTransactionalRead</name>
        <value>true</value>
        <description>reads outside of transactions</description>
    </property>

    <property>
        <name>datanucleus.readOnlyDatastore</name>
        <value>false</value>
    </property>
    <property> 
        <name>datanucleus.fixedDatastore</name>
        <value>false</value> 
    </property>

    <property> 
        <name>datanucleus.autoCreateSchema</name> 
        <value>true</value> 
    </property>

    <property>
        <name>datanucleus.autoCreateTables</name>
        <value>true</value>
    </property>
    <property>
        <name>datanucleus.autoCreateColumns</name>
        <value>true</value>
    </property>


</configuration>

3、启动
运行hive –service metastore

4、源码api

public static void main(String[] args) {  
        Connection conn = null;  
        Statement stmt = null;  
        try {  
            conn = getConn();  
            stmt = conn.createStatement();  

            // 第一步:存在就先删除  
//            String tableName = dropTable(stmt);  
            String tableName = "db_hive";  

            // 第二步:不存在就创建  
//            createTable(stmt, tableName);  

//            // 第三步:查看创建的表  
            showTables(stmt, tableName);  
//  
//            // 执行describe table操作  
//            describeTables(stmt, tableName);  
//  
//            // 执行load data into table操作  
//            loadData(stmt, tableName);  
//  
//            // 执行 select * query 操作  
//            selectData(stmt, tableName);  
//  
//            // 执行 regular hive query 统计操作  
//            countData(stmt, tableName);  

        } catch (ClassNotFoundException e) {  
            e.printStackTrace();  
            log.error(driverName + " not found!", e);  
            System.exit(1);  
        } catch (SQLException e) {  
            e.printStackTrace();  
            log.error("Connection error!", e);  
            System.exit(1);  
        } finally {  
            try {  
                if (conn != null) {  
                    conn.close();  
                    conn = null;  
                }  
                if (stmt != null) {  
                    stmt.close();  
                    stmt = null;  
                }  
            } catch (SQLException e) {  
                e.printStackTrace();  
            }  
        }  
    }  

需要源码及安装包学习,下载地址:http://47.98.237.162/detail/1/172

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇hive常用时间转换 下一篇hive中dense_rank&row_number&ran..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目