hive jdbc 连接时抛异常

Exception in thread "main" java.sql.SQLException: Could not open client transport with JDBC Uri: jdbc:hive2://192.168.137.200:10000/default: java.net.ConnectException: Connection refused: connect
     at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:215)
     at org.apache.hive.jdbc.HiveConnection.(HiveConnection.java:163)
     at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105)
     at java.sql.DriverManager.getConnection(DriverManager.java:571)
     at java.sql.DriverManager.getConnection(DriverManager.java:215)
     at HelloHive.main(HelloHive.java:17)
Caused by: org.apache.thrift.transport.TTransportException: java.net.ConnectException: Connection refused: connect
     at org.apache.thrift.transport.TSocket.open(TSocket.java:187)
     at org.apache.thrift.transport.TSaslTransport.open(TSaslTransport.java:266)
     at org.apache.thrift.transport.TSaslClientTransport.open(TSaslClientTransport.java:37)
     at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:190)
     ... 5 more
Caused by: java.net.ConnectException: Connection refused: connect
     at java.net.DualStackPlainSocketImpl.connect0(Native Method)
     at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
     at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
     at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
     at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
     at java.net.Socket.connect(Socket.java:579)
     at org.apache.thrift.transport.TSocket.open(TSocket.java:182)
     ... 8 more

在使用hive的时候启动hiveserver2正常,但是写java代码使用jdbc链接时一直报错,真的是找了两天才解决,jar包驱动全部都没错,就是运行java代码的时候报错
1. 我先检查hive server2是否启动:
netstat -anp |grep 10000
完全正常
2. 检查conf/hive-site.xml 下的配置也正常

 <configuration>
      <property> 
       <name>hive.server2.thrift.portname> 
      <value>10000value> 
    property>
    <property>
       <name>hive.server2.thrift.bind.hostname>
       <value>192.168.206.128value>
     property>
    configuration>

3 ip之间也能平通;
这是我就在想,报的是驱动错误,hiverserver2能启动,在虚拟机上使用./beeline -u jdbc:hive2://192.168.137.200:10000/default都没有问题,那最后一个可能只有是虚拟机的问题了,这是我打开vi /etc/sysconfig/networt-scripts/ifcfg-eth0,发现果然,少了一行:device=eth0,加上这一行,最终问题解决了。。。。

你可能感兴趣的:(Hadoop,Hive,hive,hive,jdbc,hiveserver2,异常)