hbase-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jilani Shaik <jilani2...@gmail.com>
Subject Not connecting to HBase using Java from web application
Date Wed, 01 Aug 2012 21:22:16 GMT
Hi,

We have a linux instance for HBase. Now I am trying to connect to HBase
using Java, when I tried using a simple program it is connecting to HBase
and doing the the operations like create and get the table rows etc.  But
the same code I used in my application as a ear file and deployed its not
running. I am not getting any exceptions also. Even I tried for
RuntimeException catching to know the problem. But still not getting the
exceptions.

Please help me in resolving this issue.

Please see the below code snippet which is running as a Java console
application.

             Configuration conf = HBaseConfiguration.create();
//conf.set("hbase.zookeeper.quorum", "10.0.100.90");  // this property
added in the hbase-site.xml
conf.addResource(new
Path("C:/jilani/workspace/hbaseproj1/src/com/demo/hbase/hbase-site.xml"));

HBaseAdmin hbase = new HBaseAdmin(conf);
 // will create a table
HTableDescriptor desc = new HTableDescriptor("demo1");
HColumnDescriptor meta = new HColumnDescriptor("personal".getBytes());
HColumnDescriptor prefix = new HColumnDescriptor("account".getBytes());
desc.addFamily(meta);
desc.addFamily(prefix);
hbase.createTable(desc);
hbase.close();
// will create a table

The same code I have used in Java file but it is packaged as jar under ear
for my application. The ear and app server both on the same box where the
java console application running. But its not working.

Thank You,
Jilani

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message