RazorSQL provides an HBase database query tool, database browser, and SQL editor. It also contains other HBase related tools such as HBase import and export tools, table editor, query builder, and more. RazorSQL can connect to HBase via either the Apache Phoenix JDBC driver or the CData JDBC driver for HBase. Listed below is information on how to get connected with either driver.

HBase Connection Help

There are two popular drivers that support connecting to HBase via JDBC. They are the open source Apache Phoenix JDBC driver and the commercial CData JDBC driver for HBase. The following links contain more information on the drivers:

Apache Phoenix: https://phoenix.apache.org/

CData: https://www.cdata.com/drivers/hbase/

Apache Phoenix Driver Information

To use the Phoenix JDBC driver for HBase, the server component of the Phoenix driver needs to be installed on the HBase server classpath.

For example, if the HBase server version is version 1.3, the corresponding Phoenix HBase server jar file should be placed in the "lib" directory under the HBase installation. Below are some example locations:

HBase installation directory: /usr/local/hbase/1.3.5 Put the following file in the /usr/local/hbase/1.3.5/libexec/lib directory: phoenix-4.14.3-HBase-1.3-server.jar

Note: Please note that the HBase versions and Phoenix versions must line up. If using HBase 1.3, for example, make sure to use the corresponding Phoenix server jar file that includes HBase-1.3 in the name.

Note: On the client side, when setting up a Phoenix connection in RazorSQL, make sure the Phoenix client jar file version lines up with the version of your HBase server. Below is an example name for HBase version 1.3:

phoenix-4.14.3-HBase-1.3-client.jar

Note: Once the Phoenix server jar file is in the HBase server classpath, the HBase server should be restarted.

Note: The Phoenix JDBC driver requires some meta data tables to be created in the HBase database. The first time a connection is made using the Phoenix JDBC driver, the driver will attempt to create the meta data tables. There is also a python script located in the Phoenix installation that can be used to create the tables. This python script is named sqlline.py

The following are the client side driver information details needed to make the connection to HBase using the Phoenix driver:

Driver Class: org.apache.phoenix.jdbc.PhoenixDriver JDBC URL Format: jdbc:phoenix:host_name:port Examples: jdbc:phoenix:localhost jdbc:phoenix:192.168.1.10:2181

To give the Phoenix driver visibility into the HBase tables, views should be created. Listed below is some example code for creating HBase tables and then the command to create the corresponding view for the Phoenix driver.

create 'actor', {NAME=>'name'} put 'actor', '1', 'name:actorName', '{firstname:"brad",lastname:"pitt"}' put 'actor', '2', 'name:actorName', '{firstname:"tom",lastname:"hanks"}' // Corresponding Phoenix view CREATE VIEW "actor" ( actorId VARCHAR PRIMARY KEY, "name"."actorName" VARCHAR)

CData HBase Driver Information

The CData HBase JDBC driver connects to HBase via the HBase Rest server. For this driver to work, the HBase Rest server must be started. Below is an example command to start the HBase Rest server. This needs to be executed in the HBase bin directory on the HBase server

./hbase rest

Once the Rest server is started, the following information can be used to connect to HBase using the CData driver:

Driver Class: cdata.jdbc.apachehbase.ApacheHBaseDriver JDBC URL Format: jdbc:apachebase:Server=hostname;Port=port Examples: jdbc:apachebase:Server=localhost;Port=8080 jdbc:apachebase:Server=192.168.1.10