zoukankan      html  css  js  c++  java
  • 9月20日

    import org.apache.hadoop.conf.Configuration;
    import org.apache.hadoop.hbase.HBaseConfiguration;
    import org.apache.hadoop.hbase.client.Connection;
    import org.apache.hadoop.hbase.client.ConnectionFactory;

    import java.io.IOException;

    public class UDB {
    public static Connection getConnection() throws IOException {
    System.out.println("weishenme");
    Configuration configuration = HBaseConfiguration.create();
    System.out.println("dingbuhzu");

    configuration.set("hbase.zookeeper.quorum","hadoop102,hadoop103,hadoop104");
    Connection connection = ConnectionFactory.createConnection(configuration);
    return connection;
    }
    //关闭连接
    public static void close(Connection connection){

    if(connection!=null){
    try {
    connection.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }
    }

    通过这样的函数获取hbase的连接,然后作为对象给操作函数进行调用。

  • 相关阅读:
    c# 遮罩
    判断当前task中的运行的activity是否为当前应用
    Chrome+SwitchySharp+myentunnel+SSH
    vps
    系统制作
    vs2010 mfc
    android ndk
    乐 Phone刷机教程(全过程)
    mysql 保留字 冲突
    mysql 存储过程
  • 原文地址:https://www.cnblogs.com/buyaoya-pingdao/p/14752568.html
Copyright © 2011-2022 走看看