@hhw 2017-11-24 09:52 采纳率: 0%
浏览 4071

hive _jdbc 连接SASL认证问题

【java代码】
package org.neworigin.hive.Hive_JDBC;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class App {
public static void main( String[] args ) throws ClassNotFoundException, SQLException {
Class.forName("org.apache.hive.jdbc.HiveDriver");
Connection conn=DriverManager.getConnection("jdbc:hive2://192.168.170.100:10000/student"," neworigin","123456 ");
PreparedStatement ppst=conn.prepareStatement("select * from jdbchive");
ResultSet rs = ppst.executeQuery();
while(rs.next()){
int id=rs.getInt("id");
String name=rs.getString("name");
int age =rs.getInt("age");
System.out.println(id+","+name+","+age);

}

conn.close();
ppst.cancel();
rs.close();
}
}
【运行结果】
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/Hw_PC/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.4.1/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/Hw_PC/.m2/repository/org/slf4j/slf4j-log4j12/1.7.10/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
12,chw,22
22,zrt,23
Exception in thread "main" java.sql.SQLException: org.apache.thrift.transport.TTransportException: SASL authentication not complete
at org.apache.hive.jdbc.HiveStatement.cancel(HiveStatement.java:174)
at org.neworigin.hive.Hive_JDBC.App.main(App.java:24)
Caused by: org.apache.thrift.transport.TTransportException: SASL authentication not complete
at org.apache.thrift.transport.TSaslTransport.write(TSaslTransport.java:474)
at org.apache.thrift.transport.TSaslClientTransport.write(TSaslClientTransport.java:37)
at org.apache.thrift.protocol.TBinaryProtocol.writeI32(TBinaryProtocol.java:178)
at org.apache.thrift.protocol.TBinaryProtocol.writeMessageBegin(TBinaryProtocol.java:106)
at org.apache.thrift.TServiceClient.sendBase(TServiceClient.java:70)
at org.apache.thrift.TServiceClient.sendBase(TServiceClient.java:62)
at org.apache.hive.service.rpc.thrift.TCLIService$Client.send_CancelOperation(TCLIService.java:484)
at org.apache.hive.service.rpc.thrift.TCLIService$Client.CancelOperation(TCLIService.java:476)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.hive.jdbc.HiveConnection$SynchronizedHandler.invoke(HiveConnection.java:1412)
at com.sun.proxy.$Proxy10.CancelOperation(Unknown Source)
at org.apache.hive.jdbc.HiveStatement.cancel(HiveStatement.java:168)
... 1 more

(库中的数据可以全部提出来,但是后面老是报认证错误。。。。。。不解。。。。)

  • 写回答

1条回答 默认 最新

  • 晨酸杏 2018-01-12 09:18
    关注

    这个问题的关键点在于,你先执行了conn.close();再去执行ppst.cancel()和rs.close();,顺序颠倒了!

    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条