Basic HBase Java Classes and Methods – Part 8: Disable and Delete a Table
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import java.io.IOException;
public class AdminDeleteTable {
public static void main(String[] args) throws IOException {
Configuration conf = HBaseConfiguration.create();
Connection connection = ConnectionFactory.createConnection(conf);
try {
Admin admin = connection.getAdmin();
TableName tableName = TableName.valueOf("employee");
if (admin.tableExists(tableName)) {
System.out.print("Table exists, Deleting.. ");
admin.disableTable(tableName);
admin.deleteTable(tableName);
System.out.println(" Done.");
} else {
System.out.println("Table does not exist.");
}
} finally {
connection.close();
}
}
}
Recent Posts
See AllOne of the biggest bottlenecks in Deep Learning is loading data. having fast drives and access to the data is important, especially if...
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.TableName;...
コメント