Phoenix - Intellij-idea创建JDBC连接

Phoenix中我们可以使用Phoenix 的sqlline.py进行连接操作,但是界面只是控制台,查看数据很不直观,SQL语句也没有提示,我们如何在IDEA中的database工具栏中直接连接Phoenix呢,这就是此文要记录的。

使用教程

保证sqlline-thin.py host能正常连接phoenix-queryserver
假设phoenix-queryserver主机在host4.demo.com主机中

[root@storm2 bin]# ./sqlline-thin.py host4.demo.com
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/bigdata/phoenix/phoenix-5.0.0-HBase-2.0-thin-client.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/hdp/3.0.0.0-1634/hadoop/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
18/08/22 22:24:41 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Setting property: [incremental, false]
Setting property: [isolation, TRANSACTION_READ_COMMITTED]
issuing: !connect jdbc:phoenix:thin:url=http://host4.demo.com:8765;serialization=PROTOBUF;authentication=SPNEGO none none org.apache.phoenix.queryserver.client.Driver
Connecting to jdbc:phoenix:thin:url=http://host4.demo.com:8765;serialization=PROTOBUF;authentication=SPNEGO
Connected to: Apache Phoenix (version unknown version)
Driver: Phoenix Remote JDBC Driver (version unknown version)
Autocommit status: true
Transaction isolation: TRANSACTION_READ_COMMITTED
Building list of tables and columns for tab-completion (set fastconnect to true to skip)...
192/192 (100%) Done
Done
sqlline version 1.2.0
0: jdbc:phoenix:thin:url=http://host4.demo>

IDEA配置database
点击设置图标

《Phoenix - Intellij-idea创建JDBC连接》 点击设置图标

新增左上角加号添加Driver
配置如下

《Phoenix - Intellij-idea创建JDBC连接》 image.png

选择Class:org.apache.phoenix.queryserver.client.Driver
Additional files:添加包 phoenix-5.0.0-HBase-2.0-thin-client.jar
添加URL templates:jdbc:phoenix:thin:url=http://{host::host4.demo.com}:8765;serialization=PROTOBUF;authentication=SPNEGO;principal=hbase@DEMO.COM;keytab=/etc/security/keytabs/hbase.headless.keytab
PS:请根据自己的配置进行修改

点击OK即可进行连接查询

SUCCESS

《Phoenix - Intellij-idea创建JDBC连接》 image.png

点赞