我需要使用jdbc连接配置单元(kerberos+ssl),我尝试了以下代码,但出现如下错误:
线程“main”java.lang.noclassdeffounderror中出现异常:org/apache/hadoop/util/versioninfo位于org.apache.hadoop.hive.shimmers.shimloader.getmajorversion(shimloader)。java:155)在org.apache.hadoop.hive.shimmes.shimloader.loadshimmes(shimloader。java:134)在org.apache.hadoop.hive.shimmers.shimloader.gethadoopthriftauthbridge(shimloader。java:120)在org.apache.hive.service.auth.httpauthutils.getkerberosserviceticket(httpauthutils。java:52)位于org.apache.hive.jdbc.httpkerberosrequestinterceptor.process(httpkerberosrequestinterceptor)。java:63)在org.apache.http.protocol.immutablehttpprocessor.process(immutablehttpprocessor。java:109)在org.apache.http.protocol.httprequestexecutor.preprocess(httprequestexecutor)。java:176)在org.apache.http.impl.client.defaultrequestdirector.execute(defaultrequestdirector。java:518)在org.apache.http.impl.client.abstracthttpclient.execute(abstracthttpclient。java:906)在org.apache.http.impl.client.abstracthttpclient.execute(abstracthttpclient。java:827)在org.apache.thrift.transport.thttpclient.flushusinghttpclient(thttpclient。java:235)在org.apache.thrift.transport.thttpclient.flush(thttpclient。java:297)在org.apache.thrift.tserviceclient.sendbase(tserviceclient。java:65)在org.apache.hive.service.cli.thrift.tcliservice$client.send\u opensession(tcliservice。java:141)在org.apache.hive.service.cli.thrift.tcliservice$client.opensession(tcliservice。java:133)在org.apache.hive.jdbc.hiveconnection.createhttptransport(hiveconnection)上。java:267)在org.apache.hive.jdbc.hiveconnection.opentransport(hiveconnection)上。java:201)在org.apache.hive.jdbc.hiveconnection.(hiveconnection。java:168)在org.apache.hive.jdbc.hivedriver.connect(hivedriver。java:105)在java.sql.drivermanager.getconnection(drivermanager。java:664)在java.sql.drivermanager.getconnection(drivermanager。java:270)在prodhive.main(prod\u test。java:25)原因:java.lang.classnotfoundexception:org.apache.hadoop.util.versioninfo版本信息
private static String driverName = "org.apache.hive.jdbc.HiveDriver";
public static void main(String[] args) throws SQLException {
try {
Class.forName(driverName);
System.out.println("Driver Registered");
} catch (ClassNotFoundException e) {
e.printStackTrace();
System.out.println("Exception Occured");
System.exit(1);
}
System.out.println("before connection");
Connection con = DriverManager.getConnection(
("jdbc:hive2://abc.xyz.com:10000/default;principal=hive/_HOST@XYZ.COM;KrbRealm=PQR.COM;KrbHostFQDN=abc.xyz.com;KrbServiceName=hive;KrbAuthType=0;SSLKeyStore=/home/arcosadmin/va.xyz.com.jks;SSLKeyStorePwd=1234;transportMode=http;httpPath=cliservice;SSL=1;AuthMech=3;UID=HS2;PWD=1234")
System.out.println("Connection Established Successfully");
Statement stmt = con.createStatement();
System.out.println("Table Creation Started");
String tableName = "hive_con";
stmt.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + "(eid int, name String,destination String)");
System.out.println("Table have been created");
con.close();
System.out.println("Connection Closed");
}
暂无答案!
目前还没有任何答案,快来回答吧!