4

I am trying to connect via : First, I added phoenix-2.jar to hbase lib directory. Then restart region server and then create a project in netbeans and add the phoenic-2-client.jar to classpath of the project. Then added below lines into hbase.site.xml for hbase and phoenix.

    <property>
<name>hbase.master</name>
<value>23.201.00.100:60000</value>
<description>The host and port the HBase master runs at. 
</description>
</property>
<property>
  <name>hbase.zookeeper.property.clientPort</name>
  <value>2222</value>
  <description>Property from ZooKeeper's config zoo.cfg.
  The port at which the clients will connect.
  </description>
</property>
<property>
  <name>hbase.zookeeper.quorum</name>
         <value>rs1.example.com,rs2.example.com,rs3.example.com,rs4.example.com,rs5.example.com</value>
  <description>Comma separated list of servers in the ZooKeeper Quorum.
  For example, "host1.mydomain.com,host2.mydomain.com,host3.mydomain.com".
  By default this is set to localhost for local and pseudo-distributed modes
  of operation. For a fully-distributed setup, this should be set to a full
  list of ZooKeeper quorum servers. If HBASE_MANAGES_ZK is set in hbase-env.sh
  this is the list of servers which we will start/stop ZooKeeper on.
  </description>
</property>
<property>
  <name>hbase.zookeeper.property.dataDir</name>
  <value>/usr/local/zookeeper</value>
  <description>Property from ZooKeeper's config zoo.cfg.
  The directory where the snapshot is stored.
  </description>
</property>

My hbase is pseodo distribiuted mode.Finally, I wrote the following code in netbeans to connect to hbase:

 Connection conn;
    Properties prop = new Properties();
      try{
        Class.forName("com.salesforce.phoenix.jdbc.PhoenixDriver");
        conn =  DriverManager.getConnection("jdbc:phoenix:rs1.example.com,rs2.example.com,rs3.example.com,rs4.example.com,rs5.example.com:2222:hdfs://localhost:8020/hbase");
        System.out.println(conn);

but shows this error:

    java.sql.SQLException: ERROR 102 (08001): Malformed connection url. jdbc:phoenix:rs1.example.com,rs2.example.com,rs3.example.com,rs4.example.com,rs5.example.com:2222:hdfs://localhost:8020/hbase
    at com.salesforce.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:146)
    at com.salesforce.phoenix.jdbc.PhoenixEmbeddedDriver$ConnectionInfo.create(PhoenixEmbeddedDriver.java:206)
    at com.salesforce.phoenix.jdbc.PhoenixDriver.getConnectionQueryServices(PhoenixDriver.java:78)
    at  com.salesforce.phoenix.jdbc.PhoenixEmbeddedDriver.connect(PhoenixEmbeddedDriver.java:115)
    at java.sql.DriverManager.getConnection(DriverManager.java:571)
    at java.sql.DriverManager.getConnection(DriverManager.java:233)
    at hbase.phoenix.HbasePhoenix.main(HbasePhoenix.java:30)
BUILD SUCCESSFUL (total time: 2 seconds)

Please guide me..

Afshin Moazami
  • 2,092
  • 5
  • 33
  • 55
Asma
  • 117
  • 1
  • 5
  • 14
  • Please use proper capitalization and indenting. I gave up editing half way. – kiheru Aug 21 '13 at 09:00
  • did you specify username and password in you xml file or connection url? – Soosh Aug 21 '13 at 09:10
  • no,i didn't difine username and password.i am not sure the code is correct or not..i dont know what to do this – Asma Aug 21 '13 at 12:12
  • have you connected to HBase without phoenix?and what does "hdfs" means in your connection url?or do you have any idea about all these? – Soosh Aug 21 '13 at 12:59
  • no,i try connect to hbase via jdbc driver but cant find it..i become confused... do you have any suggestion for connectig to hbase that i can do insert,scan,... and processing operation ..i want transform my relation db to hbase. – Asma Aug 21 '13 at 13:19
  • hdfs is the value of hbase.rootdir in hbase-site.xml file – Asma Aug 21 '13 at 13:21

4 Answers4

1

Check if this link helps.

As mentioned in the Phoenix project, the jdbc connection url should be like this : jdbc:phoenix:zookeeper1:port,zookeeper2:port

By default zookeeper listens at port 2181.

Thanks

Sankar
  • 378
  • 1
  • 4
  • 8
0

As the error clearly says, your db connect URL is malformed in getConnection method:

jdbc:phoenix:rs1.example.com,rs2.example.com,rs3.example.com,rs4.example.com,rs5.example.com:2222:hdfs://localhost:8020/hbase

I believe your jdbc connect url should look something like this:

jdbc:hbql;maxtablerefs=10;hbase.master=23.201.00.100:60000
Juned Ahsan
  • 67,789
  • 12
  • 98
  • 136
  • i think this connection url is work with hbql but i want to connect via phoenix...please help me. – Asma Aug 21 '13 at 12:16
0

Adding answer for anyone still looking:

Your jdbc connection string must look like:

jdbc:phoenix:zookeeper_quorum:2181:/hbase_znode or

jdbc:phoenix:zookeeper_quorum:/hbase_znode

(By default zookeeper listens at port 2181.)

zookeeper_quorum - Can be comma-separated server-names(must be fully qualified DNS names) hbase_znode - hbase or hbase-unsecured

e.g.

jdbc:phoenix:server1.abc.com,server2.abc.com:2181:/hbase

Community
  • 1
  • 1
viczsaurav
  • 37
  • 6
0

I used Phoenix-4.7.0-HBase-1.1. If you are running in pseud-distributed mode, you can just do connection = DriverManager.getConnection("jdbc:phoenix"); straight away. Just make sure your java program can communicate with Master, Zookeeper, and RegionServer. Check what ports and IP/hostname are being used. In my case (SSH Tunneling), I made sure the ports HMaster:16000, HQuorumPeer:2181, and HRegionServer:16201 wasn't blocked.

jpllosa
  • 2,066
  • 1
  • 28
  • 30