Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
HBase >> mail # user >> connecting Hbase using java


Copy link to this message
-
Re: connecting Hbase using java
I guess your hostname is alok, right?

Add a line line:
192.168.1.1      alok

in your hosts file by replacing the IP with your local IP.

JM

2013/4/4 Alok Singh Mahor <[EMAIL PROTECTED]>:
> sorry, actually I was copy pasting code and modifying. so I missed changing
> name of CF.
> still I am getting some error. I tried to get something from log on google
> but didnt get anything useful. I guess there is some configuration problem
> in my hbase-site.xml
>
> please look at the error at http://paste.ubuntu.com/5678610/
> what is the problem at line no. 23 ?
>
> content of /etc/hosts is
>
> 127.0.0.1       localhost
> #127.0.0.1      alok
> # The following lines are desirable for IPv6 capable hosts
> ::1     ip6-localhost ip6-loopback
> fe00::0 ip6-localnet
> ff00::0 ip6-mcastprefix
> ff02::1 ip6-allnodes
> ff02::2 ip6-allrouters
>
>
>
>
>
> On Thu, Apr 4, 2013 at 8:43 PM, Jean-Marc Spaggiari <[EMAIL PROTECTED]
>> wrote:
>
>> Alok,
>>
>> Can you take a deeper look in your code and your logs before asking
>> someone to solve that for you? ;)
>>
>> Your CF is called "myColumnFamily" and not "myLittleFamily".
>>
>> Also, I will recommand you to read some HBase related books where you
>> will learn that column familly names need to be as small as
>> possible... one byte is the best.
>>
>> JM
>>
>> 2013/4/4 Alok Singh Mahor <[EMAIL PROTECTED]>:
>> > yes thank you so much jean, I will switch to eclipse.
>> >
>> > now I tried with (java -classpath `~/packages/hbase-0.94.6/bin/hbase
>> > classpath` MyLittleHBaseClient)
>> >
>> > code is running but I guess now I have some problem with my hbase and
>> hadoop
>> >
>> > I am getting output that you can see at http://paste.ubuntu.com/5676866/
>> > could you please figure out where things are wrong now?
>> > thanks again, your reply are helping me learning basic things.
>> >
>> >
>> >
>> > On Thu, Apr 4, 2013 at 8:11 PM, Jean-Marc Spaggiari <
>> [EMAIL PROTECTED]
>> >> wrote:
>> >
>> >> Alok,
>> >>
>> >> I definitively recommand you to use an IDE to test your code. That
>> >> will help you a lot.
>> >>
>> >> Again, here, you are simply missing the classpath for you "java"
>> command.
>> >>
>> >> JM
>> >>
>> >> 2013/4/4 Alok Singh Mahor <[EMAIL PROTECTED]>:
>> >> > wow I am not getting any error now while compiling using (javac
>> >> -classpath
>> >> > `~/packages/hbase-0.94.6/bin/hbase classpath`
>> MyLittleHBaseClient.java)
>> >> >
>> >> > but this time I am getting runtime error
>> >> >
>> >> > alok@alok:~/exp/hbase/exp$ javac -classpath
>> >> > `~/packages/hbase-0.94.6/bin/hbase classpath` MyLittleHBaseClient.java
>> >> > alok@alok:~/exp/hbase/exp$ java MyLittleHBaseClient
>> >> > Exception in thread "main" java.lang.NoClassDefFoundError:
>> >> > org/apache/hadoop/hbase/HBaseConfiguration
>> >> >         at MyLittleHBaseClient.main(MyLittleHBaseClient.java:15)
>> >> > Caused by: java.lang.ClassNotFoundException:
>> >> > org.apache.hadoop.hbase.HBaseConfiguration
>> >> >         at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
>> >> >         at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
>> >> >         at java.security.AccessController.doPrivileged(Native Method)
>> >> >         at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
>> >> >         at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
>> >> >         at
>> sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
>> >> >         at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
>> >> >         ... 1 more
>> >> > alok@alok:~/exp/hbase/exp$
>> >> >
>> >> > you can see the code I am compiling at
>> http://paste.ubuntu.com/5676812/
>> >> >
>> >> > hadoop and hbase are running and I before running I had create table
>> in
>> >> > Hbase shell
>> >> >
>> >> > hbase(main):001:0> create 'myTable', 'myColumnFamily'
>> >> > 0 row(s) in 2.3800 seconds
>> >> >
>> >> > hbase(main):002:0> scan 'myTable'
>> >> > ROW
>> >> > COLUMN+CELL
>> >> >
>> >> > 0 row(s) in 0.1020 seconds