hive metastore
hive metastore是hive的元数据管理服务,实际应用中很多第三方框架需要访问metastore服务,如spark,impala等。同样hive metastore也提供了java接口。
使用
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
import org.apache.hadoop.hive.metastore.api.FieldSchema;
import org.apache.hadoop.hive.metastore.api.Table;
import org.apache.thrift.TException;
import java.util.List;
public class MetaStoreDemo {
public static void main(String[] args) throws TException {
HiveConf hiveConf = new HiveConf();
hiveConf.addResource("hive-site.xml");
HiveMetaStoreClient client = new HiveMetaStoreClient(hiveConf);
//获取数据库信息
ListtablesList = client.getAllTables("test");
System.out.print("test数据所有的表: ");
for (String s : tablesList) { <