我试图使用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<String> results = template.query("show tables");
for (String result : results) {
System.out.println(result);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} …Run Code Online (Sandbox Code Playgroud)