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

Switch to Threaded View
HBase >> mail # user >> Cannot connect to local hbase database


Copy link to this message
-
Cannot connect to local hbase database
I'm trying to connect to my hbase database via java program but I
cannot access my database because I get an error message. I checked
that the database is actually running correctly.

Java program:
public class HBaseDemo {

public static void main(String[] args )
{
try {

HTablePool pool = new HTablePool();
HTableInterface userTable = pool.getTable("users");

Put p = new Put(Bytes.toBytes("CaptainPicard"));
p.add( Bytes.toBytes("info"), Bytes.toBytes("name"),
Bytes.toBytes("Jean Luc Picard") );
p.add( Bytes.toBytes("info"), Bytes.toBytes("email"),
Bytes.toBytes("[EMAIL PROTECTED]") );
p.add( Bytes.toBytes("info"), Bytes.toBytes("password"),
Bytes.toBytes("ncc1701d") );
userTable.put( p );

Get g = new Get(Bytes.toBytes("CaptainPicard"));
g.addFamily(Bytes.toBytes("info"));

Result r = userTable.get(g);
String email    = Bytes.toString( r.getValue(
Bytes.toBytes("info"), Bytes.toBytes("email")) );
String name     = Bytes.toString( r.getValue(
Bytes.toBytes("info"), Bytes.toBytes("name")) );
String password = Bytes.toString( r.getValue(
Bytes.toBytes("info"), Bytes.toBytes("password")) );
System.out.println( "name = " + name + "\npassword = " + password +
"\nemail = " + email );
userTable.close();

} catch ( Exception e ) {
e.printStackTrace();
}
}
}
This is the output of my program:
2013-02-12 11:33:03.338 java[33339:1703] Unable to load realm info
from SCDynamicStore
13/02/12 11:33:03 INFO zookeeper.ZooKeeper: Client
environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52
GMT
13/02/12 11:33:03 INFO zookeeper.ZooKeeper: Client
environment:host.name=172.16.100.71
13/02/12 11:33:03 INFO zookeeper.ZooKeeper: Client
environment:java.version=1.7.0_09
13/02/12 11:33:03 INFO zookeeper.ZooKeeper: Client
environment:java.vendor=Oracle Corporation
13/02/12 11:33:03 INFO zookeeper.ZooKeeper: Client
environment:java.home=/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/jre
13/02/12 11:33:03 INFO zookeeper.ZooKeeper: Client
environment:java.class.path=/diverse/paths/omitted
13/02/12 11:33:03 INFO zookeeper.ZooKeeper: Client
environment:java.library.path=/Users/Tom/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
13/02/12 11:33:03 INFO zookeeper.ZooKeeper: Client
environment:java.io.tmpdir=/var/folders/0s/j6874rlj63qccjx38ltmwy880000gn/T/
13/02/12 11:33:03 INFO zookeeper.ZooKeeper: Client
environment:java.compiler=<NA>
13/02/12 11:33:03 INFO zookeeper.ZooKeeper: Client environment:os.name=Mac OS X
13/02/12 11:33:03 INFO zookeeper.ZooKeeper: Client environment:os.arch=x86_64
13/02/12 11:33:03 INFO zookeeper.ZooKeeper: Client environment:os.version=10.8.2
13/02/12 11:33:03 INFO zookeeper.ZooKeeper: Client environment:user.name=Tom
13/02/12 11:33:03 INFO zookeeper.ZooKeeper: Client
environment:user.home=/Users/Tom
13/02/12 11:33:03 INFO zookeeper.ZooKeeper: Client
environment:user.dir=/Users/Tom/Freelancing/HitFox/hbase/HBaseDemo
13/02/12 11:33:03 INFO zookeeper.ZooKeeper: Initiating client
connection, connectString=localhost:2181 sessionTimeout=180000
watcher=hconnection
13/02/12 11:33:03 INFO zookeeper.RecoverableZooKeeper: The identifier
of this process is [EMAIL PROTECTED]l
13/02/12 11:33:08 INFO zookeeper.ClientCnxn: Opening socket connection
to server fe80:0:0:0:0:0:0:1%1/fe80:0:0:0:0:0:0:1%1:2181. Will not
attempt to authenticate using SASL (unknown error)
13/02/12 11:33:08 WARN zookeeper.ClientCnxn: Session 0x0 for server
null, unexpected error, closing socket connection and attempting
reconnect
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:692)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1068)
Why is it not working?