第一步:创建maven工程,导入jar包
clouderahttps://repository.cloudera.com/artifactory/cloudera-repos/
org.apache.hadoophadoop-client2.6.0-mr1-cdh5.14.0org.apache.hbasehbase-client1.2.0-cdh5.14.0org.apache.hbasehbase-server1.2.0-cdh5.14.0junitjunit4.12testorg.testngtestng6.14.3testorg.junit.jupiterjunit-jupiter-apiRELEASEcompile
org.apache.maven.pluginsmaven-compiler-plugin3.01.8UTF-8org.apache.maven.pluginsmaven-shade-plugin2.2packageshade*:*META-INF/*.SFMETA-INF/*.DSAMETA-INF/*/RSA
第二步:开发 javaAPI 操作 HBase 表数据 删除数据表
//导的 jar包import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.*;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.filter.*;
import org.apache.hadoop.hbase.util.Bytes;import java.io.IOException;
import java.util.ArrayList;
import java.util.List;import static org.apache.hadoop.hbase.filter.CompareFilter.CompareOp.*;public class HBaseAPI {//删除数据表public static void droptable() throws IOException {//连接数据库Configuration conf=new Configuration();conf.set("hbase.zookeeper.quorum","node01:2181,node02:2181,node03:2181");Connection connection = ConnectionFactory.createConnection(conf);Admin admin = connection.getAdmin();admin.disableTable(TableName.valueOf("myuser"));admin.deleteTable(TableName.valueOf("myuser"));//关闭连接connection.close();}public static void main(String[] args) throws IOException{droptable();}}