windows安装Hive

这里写图片描述
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_hive?characterEncoding=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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值