【问题标题】:Not getting Hive databases details inside swing UI没有在 Swing UI 中获取 Hive 数据库详细信息
【发布时间】:2016-02-29 12:21:59
【问题描述】:

我正在创建一个 java swing ui,它将连接到 Hive 数据库和表,并为我提供有关 UI 本身的详细信息。

我能够生成 UI,但是除了 "default" 数据库之外,所有 Hive 数据库和表的详细信息都没有出现。但在 "default" 数据库中,我也无法获取其中存在的表。

这是检索 Hive 数据库的代码

HiveConf hconf = new HiveConf();  
HiveMetaStoreClient msClient = new HiveMetaStoreClient(hconf);  
List<String> dbs = msClient.getAllDatabases();  
System.out.println(All Databases: "+ dbs); //All Databases: [default]
List<String> tbls = msClient.getAllTables(dbName);  
System.out.println(All Tables: "+ tbls); // All Tables: []  

系统详情
Hadoop 发行版:Windows 上的 Cloudera 快速入门 VM
版本:CDH5.4.2

我的 hive-site.xml 看起来像这样

<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://127.0.0.1/metastore?createDatabaseIfNotExist=true</value>
<description>JDBC connect string for a JDBC metastore</description>
  </property>
<property>
    <name>javax.jdo.option.ConnectionDriverName</name>
    <value>com.mysql.jdbc.Driver</value>
    <description>Driver class name for a JDBC metastore</description>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionUserName</name>
    <value>hive</value>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>cloudera</value>
  </property>
  <property>
    <name>hive.hwi.war.file</name>
    <value>/usr/lib/hive/lib/hive-hwi-0.8.1-cdh4.0.0.jar</value>
    <description>This is the WAR file with the jsp content for Hive Web Interface</description>
  </property>
  <property>
    <name>hive.metastore.uris</name>
    <value>thrift://127.0.0.1:9083</value>
    <description>IP address (or fully-qualified domain name) and port of the metastore host</description>
  </property>
</configuration>

我的想法
在解决这个问题的过程中,我sysout hive conf properties

System.out.println("All Hive conf property: "+ hconf.getAllProperties().toString());  

我找到了一些使用derby数据库的属性,我不知道它是从哪里使用derby数据库的

这是我 sysout 时 hive conf 属性的一些输出

hive.stats.dbconnectionstring=jdbc:derby:;databaseName=TempStatsStore;  
hive.stats.jdbcdriver=org.apache.derby.jdbc.EmbeddedDriver  
javax.jdo.option.ConnectionURL=jdbc:derby:;databaseName=metastore_db;create=true,  
javax.jdo.option.ConnectionDriverName=org.apache.derby.jdbc.EmbeddedDriver,  

从输出看起来它正在连接到 derby 数据库,但我不明白为什么它连接到 derby 数据库,因为在我的 hive-site.xml 中提到了 mysql 数据库。

请帮帮我。

【问题讨论】:

    标签: mysql hadoop hive derby cloudera-cdh


    【解决方案1】:

    解决了这个问题。需要将 hive conf 添加为构建路径中的外部类文件夹。

    在eclipse中右键你的项目——构建路径——配置构建路径——Java构建路径——库——添加外部类文件夹——选择conf文件夹(/usr/lib/hive/ conf) -- 好的 -- 好的

    全部完成。现在我可以获取我的 Hive 数据库和表了。

    【讨论】:

      猜你喜欢
      • 2021-08-19
      • 2017-06-18
      • 2012-12-13
      • 1970-01-01
      • 2017-07-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多