Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

What dependencies I need to use phoenix jdbc installed on hbase server.

avatar
Contributor

Hi,

I have hbase server that have Phoenix installed . It is using kerberos .

phoenix-4.2.0.2.2.4.2-2-client.jar phoenix-4.2.0.2.2.4.2-2-server.jar .

I am trying to write java code where I can use phoenix jdbc driver and write a simple sql " select * from emp " .

What are the POM dependencies I need for Phoenix ?

How should My connection string look like ? I am using :

conn = DriverManager.getConnection("jdbc:" + zookeeper + ":2181/hbase-secure:principal@default_domain.com:" + keytabPath);

where principal@default_domain.com : krb.principal

1 ACCEPTED SOLUTION

avatar
Super Guru

The JDBC URL for Phoenix with Kerberos is of the form:

jdbc:phoenix:<Zookeeper_host_name>:<port_number>:<secured_Zookeeper_node>:<principal_name>:<HBase_headless_keytab_file>

You should only need the phoenix-client.jar on the classpath for your Java application for dependencies. You will likely also need the Hadoop and HBase configuration file directories (/etc/hadoop/conf and /etc/hbase/conf) on your classpath for Kerberos authentication to work properly.

View solution in original post

9 REPLIES 9

avatar
Super Guru

The JDBC URL for Phoenix with Kerberos is of the form:

jdbc:phoenix:<Zookeeper_host_name>:<port_number>:<secured_Zookeeper_node>:<principal_name>:<HBase_headless_keytab_file>

You should only need the phoenix-client.jar on the classpath for your Java application for dependencies. You will likely also need the Hadoop and HBase configuration file directories (/etc/hadoop/conf and /etc/hbase/conf) on your classpath for Kerberos authentication to work properly.

avatar
Contributor

I get Malformed connection url error from ConnectionInfo class : PhoenixEmbeddedDriver , when i use above url suggestion , not sure what I am doing wrong . Removing credentials for obvious reasons and replacing just names of server and principal .

jdbc:phoenix:d001.unix.gsm1900.org,d002.unix.gsm1900.org,d003.unix.gsm1900.org:2181:/hbase-secure:srvc@DEFAULT_DEV.com:/home/myname/krb/hdpsrvc.keytab

avatar
Contributor

Error : It enters this loop since it has more than 3 tokens . The code is fine with first 3 tokens but not more than that.protected static ConnectionInfo create(String url) { ........

if (!isMalformedUrl) { if (tokenizer.hasMoreTokens() && !TERMINATOR.equals(token)) { isMalformedUrl = true; } else if (i > 1)

avatar
Super Guru

Can you share the entire exception (with stack trace), please?

I ran the parsing code from HDP 2.2.4.2 by hand with the URL you provided and it correctly parsed out the tokens:

[d001.unix.gsm1900.org,d002.unix.gsm1900.org,d003.unix.gsm1900.org, 2181, /hbase-secure, srvc@DEFAULT_DEV.com, /home/myname/krb/hdpsrvc.keytab]

Make sure to double check that the URL you provided here is also the same as the one in your code.

avatar
Contributor

I think i am not having correct dependency , what maven dependency should i use for phoenix-client.jar . i used phoenix , incubating 4.0 version and it gives above error. When i explicitly add jar then it causes other kerberose issue , which is wrong.

avatar
Super Guru

You should use the same version of the dependency that you are running your code against: 4.2.0.2.2.4.2-2. For compile-time, you would want to use phoenix-core which will transitively include the necessary artifacts.

http://repo.hortonworks.com/content/groups/public/org/apache/phoenix/phoenix-core/4.2.0.2.2.4.2-2/ is the specific version of the artifact. You can configure this as a repository in your ~/.m2/settings.xml. Follow this Maven guide for more information

https://maven.apache.org/guides/mini/guide-multiple-repositories.html

avatar
Contributor

thank you . It works now . I was missing maven dependency .

steps : in pom.xml I added

<repositories> <repository> <id>repo.hortonworks.com</id> <name>Hortonworks HDP Maven Repository</name> <url>http://repo.hortonworks.com/content/repositories/releases/</url> </repository> </repositories>

<dependency> <groupId>org.apache.phoenix</groupId> <artifactId>phoenix-core</artifactId> <version>4.2.0.2.2.4.2-2</version> </dependency>

My connection url :

conn = DriverManager.getConnection("jdbc:phoenix:" + zookeeperQuorum + ":" + port + ":" + "/hbase-secure" + ":" + krb_principal + ":" + kerberosKeytab);

avatar
Contributor

Hey Guys,

I get below error when i use keytab path as below for phoenix jdbc connection . Can anyone please help me here . I have keytab file locally on my laptop.

keytab.path=C\:\\Users\\VBorhad\\krbProperties\\hdpsrvc.keytab

Error :

java.sql.SQLException: ERROR 102 (08001): Malformed connection url. jdbc:phoenix:p006.unix.gsm1900.org,p001.unix.gsm1900.org,p002.unix.gsm1900.org,p003.unix.gsm1900.org:2181:/hbase-secure:srvc@HDP_EIT_DEV.com:C:\Users\VBorhad\krbProperties\hdpsrvc.keytab at org.apache.phoenix.exception.SQLExceptionCode$Factory$1.newException(SQLExceptionCode.java:337) at org.apache.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:133)

avatar
Super Guru

I saw you had already asked this question over at https://community.hortonworks.com/questions/7887/phoenix-throws-malformed-url-error-when-keytab-pat..... Let's address this issue there. Thanks.