问题描述
try {
Class.forName("org.apache.hive.jdbc.HiveDriver");
Connection con = DriverManager.getConnection("jdbc:hive2://host:port","user","nc_admin");
System.out.println(con);
Statement stmt = con.createStatement();
System.out.println(stmt);
} catch (ClassNotFoundException e) {
e.printstacktrace();
} catch (sqlException e) {
e.printstacktrace();
}
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient
解决方法
如果是maven项目,请使用此pom。
<!-- https://mvnrepository.com/artifact/org.apache.hive/hive-jdbc -->
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>3.1.2</version>
</dependency>
或从此处下载罐子