您好,登錄后才能下訂單哦!
這篇文章主要講解了“java調(diào)用zookeeper模式報(bào)錯問題怎么處理”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“java調(diào)用zookeeper模式報(bào)錯問題怎么處理”吧!
1.調(diào)用方式 zookeeper方式調(diào)用
/** *@Title TestHive.java *@description TODO *@time 2020年12月24日 下午1:27:38 *@version 1.0 **/ package org.thedatamanager.dataCollectionService; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; /** * */ public class TestHive { /** * @Title: main * @Description: * @param args * @return void * @date 2020年12月24日下午1:27:38 */ public static void main(String[] args) { try { Class.forName("org.apache.hive.jdbc.HiveDriver"); //Connection conn = DriverManager.getConnection("jdbc:hive2://10.60.127.131:10000", "hive", ""); // Connection conn = DriverManager.getConnection("jdbc:hive2://192.168.1.135:10000/default;auth=noSasl", "hive", "hive"); Connection conn = DriverManager.getConnection("jdbc:hive2://192.168.1.134:2181,192.168.1.135:2181,192.168.1.136:2181/default;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2", "root", "root"); // default 為 hive的數(shù)據(jù)庫名 Statement stmt = conn.createStatement(); String querySQL="show databases"; ResultSet res = stmt.executeQuery(querySQL); while (res.next()) { System.out.println(res.getString(1)); } } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } } }
報(bào)錯class undefined找不到curator connection
2.問題
解決方法:,將低版本的hive-jdbc中curator-client低版本的移除 引入高版本的4.0.1
<!-- hive 調(diào)用需要的包 --> <dependency> <groupId>org.apache.hive</groupId> <artifactId>hive-jdbc</artifactId> <version>3.1.0</version> <exclusions> <exclusion> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> </exclusion> <exclusion> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-slf4j-impl</artifactId> </exclusion> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion> <exclusion> <groupId>org.eclipse.jetty</groupId> <artifactId>*</artifactId> </exclusion> <exclusion> <groupId>org.eclipse.jetty.orbit</groupId> <artifactId>*</artifactId> </exclusion> <exclusion> <groupId>org.eclipse.jetty.aggregate</groupId> <artifactId>*</artifactId> </exclusion> <exclusion> <groupId>tomcat</groupId> <artifactId>*</artifactId> </exclusion> <exclusion> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> </exclusion> <exclusion> <groupId>org.mortbay.jetty</groupId> <artifactId>*</artifactId> </exclusion> <exclusion> <groupId>org.apache.curator</groupId> <artifactId>curator-client</artifactId> </exclusion> </exclusions> </dependency> <!-- 找不到class undefined問題找不到 curator connection,將低版本的hive-jdbc中curator-client低版本的移除 引入高版本的4.0.1 --> <dependency> <groupId>org.apache.curator</groupId> <artifactId>curator-client</artifactId> <version>4.0.1</version> </dependency>
感謝各位的閱讀,以上就是“java調(diào)用zookeeper模式報(bào)錯問題怎么處理”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對java調(diào)用zookeeper模式報(bào)錯問題怎么處理這一問題有了更深刻的體會,具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識點(diǎn)的文章,歡迎關(guān)注!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。