Created 02-26-2019 03:41 PM
I am not specifying anything about the hbase server or the zookeeper but this code works fine and hbase table gets created , how does the code know where to connect to hbase server?
[root@hadoop1 ~]# more TestHbaseTable.java
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.client.HBaseAdmin;
public class TestHbaseTable
{
public static void main(String[] args) throws IOException
{
HBaseConfiguration hconfig = new HBaseConfiguration(new Configuration());
HTableDescriptor htable = new HTableDescriptor("User");
htable.addFamily( new HColumnDescriptor("Id"));
htable.addFamily( new HColumnDescriptor("Name"));
System.out.println( "Connecting..." );
HBaseAdmin hbase_admin = new HBaseAdmin( hconfig );
System.out.println( "Creating Table..." );
hbase_admin.createTable( htable );
System.out.println("Done!");
}
}
Created 02-26-2019 03:46 PM
You are running the application in a way that includes the directory containing hbase-site.xml on the classpath.
Created 02-26-2019 04:05 PM
so if the hbase-site.xml directory is in the classpath then no connection information needs to be given in the java code?