Jdbc连接Hive数据库


Jdbc连接Hive数据库通常会遇到:

    报错:jdbc:hive2://master0.example.com:10000: Java.NET.ConnectException: Connection refused: connect


Jdbc连接Hive数据库_第1张图片

 首先来看下maven的配置文件:
Jdbc连接Hive数据库_第2张图片

接着是hive-site.xml文件:
              
               hive.server2.thrift.port 
              10000 
            
            
               hive.server2.thrift.bind.host
               master0.example.com
             
我的hive库hadoop中表person是这样的:
                 Jdbc连接Hive数据库_第3张图片

 接着开启终端hiveservice2服务:
      [student@master0 hive-1.1.0-cdh5.8.5]$ hive --service hiveserver2   
启动后查看端口是否已经开启:[root@master0 student]# netstat -ntpl |grep 10000
这样说明已经成功:
      [root@master0 student]# netstat -ntpl |grep 10000
      tcp        0      0 0.0.0.0:10000               0.0.0.0:*                   LISTEN      28394/java 

最终执行结果:
Jdbc连接Hive数据库_第4张图片
        祝你早日胜利!
顺便提一下:在你的工具上要在resource中加入配置文件:
          

你可能感兴趣的:(Hive)