小编moh*_*rma的帖子

如何在Hive-Site.xml文件中设置hive Metastore连接的配置?

我想使用java代码连接MetaStore.我不知道如何在Hive-Site.xml文件中设置配置设置以及我将发布Hive-Site.xml文件的位置.请帮忙.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.conf.HiveConf.ConfVars;

public class HiveMetastoreJDBCTest {

    public static void main(String[] args) throws Exception {

        Connection conn = null;
        try {
            HiveConf conf = new HiveConf();
            conf.addResource(new Path("file:///path/to/hive-site.xml"));
            Class.forName(conf.getVar(ConfVars.METASTORE_CONNECTION_DRIVER));
            conn = DriverManager.getConnection(
                    conf.getVar(ConfVars.METASTORECONNECTURLKEY),
                    conf.getVar(ConfVars.METASTORE_CONNECTION_USER_NAME),
                    conf.getVar(ConfVars.METASTOREPWD));

            Statement st = conn.createStatement();
            ResultSet rs = st.executeQuery(
                "select t.tbl_name, s.location from tbls t " +
                "join sds s on t.sd_id = s.sd_id");
            while (rs.next()) {
                System.out.println(rs.getString(1) + " : " + rs.getString(2)); …
Run Code Online (Sandbox Code Playgroud)

hadoop hive cloudera impala metastore

5
推荐指数
1
解决办法
2万
查看次数

NameError:未初始化的常量SingleColumnValueFilter

我正在尝试使用此代码使用hbase过滤器,

hbase(main):001:0>扫描'students',{FILTER => SingleColumnValueFilter.new(Bytes.toBytes('account'),Bytes.toBytes('name'),CompareFilter :: CompareOp.valueOf('EQUAL' ),BinaryComparator.new(Bytes.toBytes( 'EMP1')))}

并且此代码给出错误,如 NameError:uninitialized constant SingleColumnValueFilter

请让我知道我做错了什么或我需要做什么来获得过滤结果.

hbase cloudera

3
推荐指数
1
解决办法
3979
查看次数

标签 统计

cloudera ×2

hadoop ×1

hbase ×1

hive ×1

impala ×1

metastore ×1