使用Spring挂起查询远程Hive server2

 --AppleChan-- 发布于 2022-12-04 15:52

我试图使用Spring和jdbc连接连接到Hive.我正在使用Spring Book中的相同示例(https://github.com/spring-projects/spring-hadoop-samples/tree/master/hive)并且我获得了连接部分,但是当我运行查询时它变得悬而未决,我再也没有得到结果.

我看到更多的帖子有类似于这个的问题,但没有一个回答具体/工作的答案.

有人可以帮帮我吗?我开始认为Hive Server 2和spring框架存在问题.

这是我的代码:

public class HiveApp {

private static final Log log = LogFactory.getLog(HiveApp.class);

public static void main(String[] args) throws Exception {
    try {
        AbstractApplicationContext context = new ClassPathXmlApplicationContext(
                "/META-INF/spring/hive-context.xml", HiveApp.class);
        log.info("Hive Application Running");
        System.out.println("Hive Application Running");
        context.registerShutdownHook(); 

        HiveTemplate template = context.getBean(HiveTemplate.class);
        System.out.println("Hive Template = " + template);
        List results = template.query("show tables");
        for (String result : results) {
            System.out.println(result);         
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

这是我的hive-context.xml











    fs.default.name=${hd.fs}




          

  

      



这是我的jdbc-context.xml







  
  



  



这是我的hive.properties

hive.host=somehost.int
hive.port=10000
hive.url=jdbc:hive2://${hive.host}:${hive.port}/
hive.table=tablename

这是我的hive-server.properties hive.exec.drop.ignorenonexistent = true

这是我的POM


4.0.0

spring-data-book-hadoop-hive

Spring Data Book - Hadoop Hive


    com.oreilly.springdata
    spring-data-book
    1.0.0.BUILD-SNAPSHOT
    ../../pom.xml



    UTF-8
    1.0.0.RELEASE
    2.1.3.RELEASE      
    1.0.1
    0.8.1
    0.7.0
    1.2.17




    
        org.springframework.data
        spring-data-hadoop
        ${spring.hadoop.version}
        
            
                org.springframework
                spring-context-support
            
            
                org.slf4j
                slf4j-log4j12
            
                        
     

    
        org.springframework
        spring-jdbc
        ${spring.version}
    
    
        org.springframework
        spring-test
        ${spring.version}
           

    
        org.springframework
        spring-tx
        ${spring.version}
    

    
        org.springframework.integration
        spring-integration-core
        ${spring.integration.version}
           

    
        org.apache.hadoop
        hadoop-core
        ${hadoop.version}
        compile
    

    
        org.apache.hive
        hive-metastore
        ${hive.version}
        
             
                org.slf4j
                slf4j-log4j12
            
             
                log4j
                log4j
            
                    
    

    
        org.apache.hive
        hive-service
        ${hive.version}      
        
            
                org.slf4j
                slf4j-log4j12
            
             
                log4j
                log4j
            
                   
       

    
    
        org.apache.thrift
        libthrift
        ${thrift.version}
               

    
        org.apache.thrift
        libfb303
        ${thrift.version}
                   

    

    
        org.apache.hive
        hive-common
        ${hive.version}
        runtime
           

    
        org.apache.hive
        hive-builtins
        ${hive.version}
        runtime
               

    
        org.apache.hive
        hive-jdbc
        ${hive.version}
        runtime
               

    
        org.apache.hive
        hive-shims
        ${hive.version}
        runtime
               

    
        org.apache.hive
        hive-serde
        ${hive.version}
        runtime
        
             
                org.slf4j
                slf4j-log4j12
            
             
                log4j
                log4j
            
                       
                   

    
        org.apache.hive
        hive-contrib
        ${hive.version}
        runtime
    
          

    
        org.codehaus.groovy
        groovy
        1.8.5
        runtime
                       

    
        ch.qos.logback
        logback-classic
        ${logback.version}
    




    
        spring-milestone
        http://repo.springsource.org/libs-milestone
    



    
        
            org.codehaus.mojo
            appassembler-maven-plugin
            1.2.2
            
                flat
                
                -Xms512m -Xmx1024m
                
                    
                        com.oreilly.springdata.hadoop.hive.HiveApp
                        hiveApp
                    
                    
                        com.oreilly.springdata.hadoop.hive.HiveAppWithApacheLogs
                        hiveAppWithApacheLogs
                              
                
            
        
        
            org.apache.maven.plugins
            maven-antrun-plugin
            
                
                    config
                    package
                    
                        
                            
                                
                            
                        
                    
                    
                        run
                    
                
            
               
    

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有