单线连接HBase
public class HBaseConnection {
public static void main(String[] args) throws IOException {
Configuration conf = new Configuration();
conf.set("hbase.zookeeper.quorum","node1.itcast.cn,node2.itcast.cn,node3.itcast.cn");
Connection conn = ConnectionFactory.createConnection(conf);
System.out.println(conn);
conn.close();
}
}
多线连接HBase
public class HBaseConnection2 {
public static Connection conn = null;
static {
try {
conn = ConnectionFactory.createConnection();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void closeConnection() throws IOException {
if(conn != null){
conn.close();
}
}
标签:itcast,cn,public,static,conf,HBase,连接,conn From: https://www.cnblogs.com/csj-717/p/16725346.html