0
我已經安裝在我的本地一個Cloudera的碼頭工人容器蜂巢連接,也蜂巢端口配置,這樣 docker run --hostname=quickstart.cloudera --privileged=true -t -i -p 8888:8888 -p 80:80 -p 10000:10000 --name cloudera2 cloudera/quickstart /usr/bin/docker-quickstart
使用JDBC在Cloudera的搬運工
我想將它與JDBC連接,我的代碼是這樣對此,
val driver = "org.apache.hive.jdbc.HiveDriver"
val url = "jdbc:hive2://localhost:10000/default"
val username = ""
val password = ""
// there's probably a better way to do this
var connection: Connection = null
try {
// make the connection
Class.forName(driver)
} catch {
case e => e.printStackTrace
}
connection = DriverManager.getConnection(url, username, password)
connection.close()
但發生NoClassDefFoundError
當我嘗試執行它
log4j:WARN No appenders could be found for logger (org.apache.hive.jdbc.Utils).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/conf/Configuration
at org.apache.hive.jdbc.HiveConnection.createUnderlyingTransport(HiveConnection.java:362)
at org.apache.hive.jdbc.HiveConnection.createBinaryTransport(HiveConnection.java:382)
at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:193)
at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:167)
at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at ScalaJdbcConnectSelect$.main(ScalaJdbcConnectSelect.scala:32)
蜂巢版本:
Hive 1.1.0-cdh5.7.0
行家依賴
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>1.1.0-cdh5.7.0</version>
</dependency>
我不知道這是因爲用戶名和密碼,但我已經試過"cloudera","cloudera" "hive","", and "",""