Now we will make HBase table in Eclipse.
Step 1. Create Java Class file
Step 2. fill information
.Package: the package name for your code (any name is OK)
.Name : Your Java Class name (any name is OK)
.Check "public static void main...."
Source Code
package org.hadoop.dna;
import java.io.IOException;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.fs.Path;
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 SnortTable {
/**
* @param args
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
HTableDescriptor descriptor = new HTableDescriptor("SnortTable");
descriptor.addFamily(new HColumnDescriptor("sig"));
descriptor.addFamily(new HColumnDescriptor("priority"));
try {
Configuration config = HBaseConfiguration.create();
config.addResource(new Path("/usr/local/hbase/conf/hbase-default.xml"));
config.addResource(new Path("/usr/local/hbase/conf/hbase-site.xml"));
HBaseAdmin admin = new HBaseAdmin(config);
// Create Table
admin.createTable(descriptor);
System.out.println("Table Created...");
} catch (IOException e) {
System.out.println("IOExeption: cannot create table");
e.printStackTrace();
}
}
}