Using SQL and APIs with Apache Phoenix

You can create and interact with Apache HBase tables in the form of typical DDL/DML statements through its standard JDBC API. Apache Phoenix JDBC driver can be easily embedded in any app that supports JDBC.

Apache Phoenix has two kinds of JDBC drivers, thick and thin. The thick driver communicates directly with Apache ZooKeeper and Apache HBase and the thin client communicates with Apache HBase through Phoenix Query Server.

To connect to Apache Phoenix using the "thick" JDBC driver, you must use the JDBC URL syntax as shown here:
jdbc:phoenix:[comma-separated ZooKeeper Quorum [:port [:hbase root znode [:kerberos_principal [:the path to kerberos keytab] ] ] ]
Example URL
jdbc:phoenix:zookeeper1.domain,zookeeper2.domain,
zookeeper3.domain:2181:/hbase:phoenix@EXAMPLE.COM:/etc/security/keytabs/phoenix.keytab

If you are running your client on the Apache Phoenix cluster, you do not have to specify the ZooKeeper parameter; the ZooKeeper quorum is retrieved automatically from hbase-site.xml configuration file.

You can use the standard JDBC APIs instead of the regular HBase client APIs to create tables, insert data, and query your HBase data.

The following drivers are currently supported

  • JDBC driver
  • ODBC driver
  • Other non-Java drivers (example, Microsoft .Net driver and Python driver)

Obtaining a driver for application development

Based on your application development requirements, you can obtain one of the following drivers:

JDBC driver

Use the /opt/cloudera/parcels/CDH/lib/phoenix/phoenix-5.0.0.7.2.0.0-128-client.jar file in the Phoenix server-client repository.

ODBC driver

Use the Database Open Database Connectivity (ODBC) interface to access the operational database. The ODBC driver is provided by Cloudera as an additional download, but you can also use ODBC drivers from third-party providers.

You can download the Phoenix ODBC Driver from here: https://www.cloudera.com/downloads/hdp.html.

Other non-Java drivers

Other non-JDBC Drivers for Phoenix are available as add-ons and on other websites, but they are not currently supported by Cloudera. You can find compatible client drivers by searching on the web for avatica and the name of an application programming language that you want to use. For example: avatica python. For more information and links to driver download pages, see https://calcite.apache.org/avatica/docs/.

Microsoft .NET Driver

Download and install a NuGet package for Microsoft .NET Driver for Apache Phoenix. For more information, see https://www.nuget.org/packages/Microsoft.Phoenix.Client/.

Python Driver for Phoenix

Download the Python Driver for Apache Phoenix from the Apache Phoenix website. For more information, see http://phoenix.apache.org/python.html.