1、在pom文件中加入jar包
·
org.apache.phoenix
phoenix-core
4.14.0-HBase-1.2
2、写一个测试,检验是否可以建立连接
·public static void main(String[] args) {
Properties props = new Properties();
props.setProperty(“phoenix.query.timeoutMs”, “1200000”);
props.setProperty(“hbase.rpc.timeout”, “1200000”);
props.setProperty(“hbase.client.scanner.timeout.period”, “1200000”);
try {
Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");
// 这里配置zookeeper的地址,可单个,也可多个。可以是域名或者ip
String url = "jdbc:phoenix:172.26.xx.xx,172.26.xx.xx,172.26.xx.xx:2181:/hbase-unsecure";
Connection conn = DriverManager.getConnection(url, props);
System.out.println(conn);
Statement statement = conn.createStatement();
String sql = "select count(1) from order_1 limit 10";
long time = System.currentTimeMillis();
ResultSet rs &#