http://squirrel-sql.sourceforge.net/
http://archive.apache.org/dist/phoenix/apache-phoenix-4.10.0-HBase-1.1/bin/apache-phoenix-4.10.0-HBase-1.1-bin.tar.gz
http://squirrel-sql.sourceforge.net/index.php?page=screenshots
双击squirrel-sql-3.8.1-standard.jar
直接下一步下一步即可
解压 apache-phoenix-4.10.0-HBase-1.1-bin.tar.gz
将phoenix-4.10.0-HBase-1.1-client.jar 放入 squirrel安装目录的lib
启动SQuirrel客户端,选择 Drivers-new driver ,名称自定义别名,
url格式: jdbc:phoenix:(zookeeper地址),
class name textbox 填写org.apache.phoenix.jdbc.PhoenixDriver
add driver :master已经在我本机host里边做了映射
0: jdbc:phoenix:localhost:2181:/hbase> select* from user;
+-----+-------+--------+
| ID | NAME | ADDR |
+-----+-------+--------+
| 1 | lisa | china |
| 2 | 李宗盛 | 台北 |
| 3 | 周华健 | 台北 |
| 4 | 一言难尽 | 台北 |
+-----+-------+--------+
4 rows selected (0.054 seconds)
0: jdbc:phoenix:localhost:2181:/hbase>
package com.demo.hbase.test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.PreparedStatement;
import java.sql.Statement;
public class PhoenixTest {
public static void main(String[] args) throws SQLException, ClassNotFoundException {
Statement stmt = null;
ResultSet rset = null;
Connection con = DriverManager.getConnection("jdbc:phoenix:master:2181:hbase");
/*stmt = con.createStatement();
stmt.executeUpdate("create table test (mykey integer not null primary key, mycolumn varchar)");
stmt.executeUpdate("upsert into test values (1,'Hello')");
stmt.executeUpdate("upsert into test values (2,'World!')");
con.commit();*/
PreparedStatement statement = con.prepareStatement("select * from user");
rset = statement.executeQuery();
System.out.println("======================query result============================");
while (rset.next()) {
String id = rset.getString("id");
String name = rset.getString("name");
String addr = rset.getString("addr");
System.out.println(String.format("id=%s,name=%s,addr=%s", id,name,addr));
}
statement.close();
con.close();
}
}
Iterator ready: org.apache.phoenix.iterate.RoundRobinResultIterator@31024624
[DEBUG] 2018-07-27 14:59:09,644 method:org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:293)
Explain plan: CLIENT 1-CHUNK PARALLEL 1-WAY ROUND ROBIN FULL SCAN OVER USER
======================query result============================
[DEBUG] 2018-07-27 14:59:09,654 method:org.apache.phoenix.iterate.BaseResultIterators.getIterators(BaseResultIterators.java:780)
Getting iterators for ResultIterators [name=PARALLEL,id=1ed63511-1d44-3bfc-328d-f3dbe6cb610b,scans=[[{"loadColumnFamiliesOnDemand":null,"startRow":"","stopRow":"","batch":-1,"cacheBlocks":true,"totalColumns":1,"maxResultSize":-1,"families":{"0":["ALL"]},"caching":2147483647,"maxVersions":1,"timeRange":[0,1532674749291]}]]]
[DEBUG] 2018-07-27 14:59:09,654 method:org.apache.phoenix.iterate.ParallelIterators$1.call(ParallelIterators.java:112)
Id: 1ed63511-1d44-3bfc-328d-f3dbe6cb610b, Time: 0ms, Scan: {"loadColumnFamiliesOnDemand":null,"startRow":"","stopRow":"","batch":-1,"cacheBlocks":true,"totalColumns":1,"maxResultSize":-1,"families":{"0":["ALL"]},"caching":2147483647,"maxVersions":1,"timeRange":[0,1532674749291]}
id=1,name=lisa,addr=china
id=2,name=李宗盛,addr=台北
id=3,name=周华健,addr=台北
id=4,name=一言难尽,addr=台北