我用jdbc连接hiveserver2,但出现了如下异常:hive版本1.2.1 beeline连接良好
[mw_shl_code=applescript,true]def main(args: Array[String]): Unit = {
val driverName: String = "org.apache.hive.jdbc.HiveDriver"
val Url: String = "jdbc:hive2://node1:10000/" //填写hive的IP,之前在配置文件中配置的IP
var conn: Connection = null
Class.forName(driverName)
conn = DriverManager.getConnection(Url,"root","123456")
var ps: PreparedStatement = null
ps = conn.prepareStatement("show databases")
val set = ps.executeQuery()
while (set.next()) {
println(set.getString(0))
}
}[/mw_shl_code]
[mw_shl_code=applescript,true]Exception in thread "main" org.apache.hive.service.cli.HiveSQLException
at org.apache.hive.jdbc.Utils.verifySuccess(Utils.java:256)
at org.apache.hive.jdbc.Utils.verifySuccess(Utils.java:247)
at org.apache.hive.jdbc.HiveConnection.openSession(HiveConnection.java:586)
at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:192)
at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at com.test.env.metaschema.HiveServer2TestMain$.main(HiveServer2TestMain.scala:12)
at com.test.env.metaschema.HiveServer2TestMain.main(HiveServer2TestMain.scala)
Caused by: org.apache.hive.service.cli.HiveSQLException: null
at org.apache.hive.service.cli.session.HiveSessionImpl.<init>(HiveSessionImpl.java:109)
at org.apache.hive.service.cli.session.SessionManager.openSession(SessionManager.java:252)
at org.apache.spark.sql.hive.thriftserver.SparkSQLSessionManager.openSession(SparkSQLSessionManager.scala:70)
at org.apache.hive.service.cli.CLIService.openSession(CLIService.java:194)
at org.apache.hive.service.cli.thrift.ThriftCLIService.getSessionHandle(ThriftCLIService.java:365)
at org.apache.hive.service.cli.thrift.ThriftCLIService.OpenSession(ThriftCLIService.java:257)
at org.apache.hive.service.cli.thrift.TCLIService$Processor$OpenSession.getResult(TCLIService.java:1253)
at org.apache.hive.service.cli.thrift.TCLIService$Processor$OpenSession.getResult(TCLIService.java:1238)
at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39)
at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39)
at org.apache.hive.service.auth.TSetIpAddressProcessor.process(TSetIpAddressProcessor.java:56)
at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:285)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)[/mw_shl_code]
|