| | 6 | package tsmc; |
| | 7 | |
| | 8 | import java.io.IOException; |
| | 9 | |
| | 10 | import org.apache.hadoop.hbase.HBaseConfiguration; |
| | 11 | import org.apache.hadoop.hbase.client.HBaseAdmin; |
| | 12 | |
| | 13 | public class DropTable { |
| | 14 | |
| | 15 | static void drop(String tablename) { |
| | 16 | HBaseConfiguration conf = new HBaseConfiguration(); |
| | 17 | HBaseAdmin admin; |
| | 18 | try { |
| | 19 | admin = new HBaseAdmin(conf); |
| | 20 | if (admin.tableExists(tablename)) |
| | 21 | { |
| | 22 | admin.disableTable(tablename); |
| | 23 | admin.deleteTable(tablename); |
| | 24 | System.out.println("Droped the table [" + tablename+ "]"); |
| | 25 | }else{ |
| | 26 | System.out.println("Table [" + tablename+ "] was not found!"); |
| | 27 | } |
| | 28 | |
| | 29 | } catch (IOException e) { |
| | 30 | e.printStackTrace(); |
| | 31 | } |
| | 32 | } |
| | 33 | public static void main(String[] argv) { |
| | 34 | drop("testtable"); |
| | 35 | } |
| | 36 | } |