Hive JDBC Connection返回“查询未生成结果集”

时间:2016-07-01 16:52:40

标签: hadoop jdbc hive

我已经从git构建了hive-jdbc并尝试执行基本的jdbc查询来获取结果集。由于某种原因,查询抛出以下异常。

16/07/01 22:08:12 INFO Utils: Supplied authorities: localhost:10000 
16/07/01 22:08:12 INFO Utils: Resolved authority: localhost:10000 
16/07/01 22:08:12 DEBUG TSaslTransport: opening transport org.apache.thrift.transport.TSaslClientTransport@55360888 
16/07/01 22:08:12 DEBUG TSaslClientTransport: Sending mechanism name PLAIN and initial response of length 16 
16/07/01 22:08:12 DEBUG TSaslTransport: CLIENT: Writing message with status START and payload length 5 
16/07/01 22:08:12 DEBUG TSaslTransport: CLIENT: Writing message with status COMPLETE and payload length 16 
16/07/01 22:08:12 DEBUG TSaslTransport: CLIENT: Start message handled 
16/07/01 22:08:12 DEBUG TSaslTransport: CLIENT: Main negotiation loop complete 
16/07/01 22:08:12 DEBUG TSaslTransport: CLIENT: SASL Client receiving last message 
16/07/01 22:08:12 DEBUG TSaslTransport: CLIENT: Received message with status COMPLETE and payload length 0 
16/07/01 22:08:12 DEBUG TSaslTransport: writing data length: 71 
16/07/01 22:08:12 DEBUG TSaslTransport: CLIENT: reading data length: 109 
16/07/01 22:08:12 DEBUG TSaslTransport: writing data length: 183 
16/07/01 22:08:12 DEBUG TSaslTransport: CLIENT: reading data length: 109 
16/07/01 22:08:12 DEBUG TSaslTransport: writing data length: 100 
16/07/01 22:08:12 DEBUG TSaslTransport: CLIENT: reading data length: 53 
Exception in thread "main" java.sql.SQLException: The query did not generate a result set!  
   at org.apache.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:459)   
   at com.kris.mond.sample.HiveQuery.main(HiveQuery.java:20)

以下是我正在使用的代码片段

     try { 
         Class.forName("org.apache.hive.jdbc.HiveDriver");
        } catch (ClassNotFoundException e) { 
            System.err.println("Could not load the driver");
            System.exit(1);
        } 
     Connection con = DriverManager.getConnection("jdbc:hive2://localhost:10000/default", "hduser", "*******");
     Statement stmt = con.createStatement();
     ResultSet rs = stmt.executeQuery("select account_id,account_parent,account_description from account");

正如另一篇文章所述,我使用的是executeQuery for DML但仍无法获取结果集。

我希望得到一些帮助。 在此先感谢。

1 个答案:

答案 0 :(得分:1)

我已经设法在HiveStatement.java中的以下补丁之后获取结果集

for index, row in df.iteritems():
    p = figure()
    p.scatter(df['Sample'], df[row])
    show(p)

出于某种原因,即使结果集可用, status.isHasResultSet()也会返回false。