Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created on 11-26-2015 10:32 PM - edited 09-16-2022 02:50 AM
I am creating a java swing ui which will connect to Hive databases and tables and provide me the details on UI itself.
I am able to generate the UI but details of all Hive databases and tables are not comming except the "default" database. But inside "default" database also I am not able to get the tables present inside it.
Here is the code to retrieve the Hive database
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: []
System details
Hadoop distribution: Cloudera Quickstart VM on Windows
version: CDH5.4.2
My hive-site.xml looks like this
<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>
My thought
In the process to solve this issue, I sysout hive conf properties
System.out.println("All Hive conf property: "+ hconf.getAllProperties().toString());
I found some properties where it uses derby database, I don't know from where it is using derby database
here are some output of hive conf properties when I sysout it
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,
From the output it looks it is connecting to derby database, but I am not getting why it is connecting to derby database, since in my **hive-site.xml** It is mentioned mysql database.
Please help me out in this.
Created 11-27-2015 01:18 AM
Resolved the issue. Need to add hive conf as external class folder in your build path.
Right click on you project in eclipse -- Build Path -- Configure Build Path -- Java Build Path -- Libraries -- Add External Class Folder -- select the conf folder (/usr/lib/hive/conf) -- OK -- OK
All done. Now I am able to get my hive databases and tables.
Created 11-27-2015 01:18 AM
Resolved the issue. Need to add hive conf as external class folder in your build path.
Right click on you project in eclipse -- Build Path -- Configure Build Path -- Java Build Path -- Libraries -- Add External Class Folder -- select the conf folder (/usr/lib/hive/conf) -- OK -- OK
All done. Now I am able to get my hive databases and tables.