xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

資源簡(jiǎn)介

本代碼是java鏈接并對(duì)hbase進(jìn)行增刪改查操作的實(shí)例代碼,并包括批量插入,范圍查詢等,并包含所需jar包.

資源截圖

代碼片段和文件信息

/**
?*?
?*/
package?whg.hbase;

import?org.apache.hadoop.conf.Configuration;
import?org.apache.hadoop.hbase.Cell;
import?org.apache.hadoop.hbase.CellUtil;
import?org.apache.hadoop.hbase.HbaseConfiguration;
import?org.apache.hadoop.hbase.HColumnDescriptor;
import?org.apache.hadoop.hbase.HTableDescriptor;
import?org.apache.hadoop.hbase.NamespaceDescriptor;
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?org.apache.hadoop.hbase.client.Delete;
import?org.apache.hadoop.hbase.client.Get;
import?org.apache.hadoop.hbase.client.Put;
import?org.apache.hadoop.hbase.client.Result;
import?org.apache.hadoop.hbase.client.Table;
import?org.apache.hadoop.hbase.util.Bytes;

/**
?*?
?*?

類描述:hbase?增刪改查操作??


?*?

創(chuàng)建人:wanghonggang??


?*?

創(chuàng)建時(shí)間:2018年11月27日?下午3:18:10??


?*/
public?class?HbaseCRUD?{

//hbase?鏈接
static?Connection?conn;

//?數(shù)據(jù)庫(kù)元數(shù)據(jù)操作對(duì)象
????static?Admin?admin;

/**
?*?@param?args
?*/
public?static?void?main(String[]?args)?{
//?TODO?Auto-generated?method?stub
try?{
System.out.println(“---------------??開(kāi)始!????-----------------“);
setup();//初始化
createTable();//創(chuàng)建表
insert();//插入數(shù)據(jù)
update();//更新數(shù)據(jù)
delete();//刪除數(shù)據(jù)
select();//查詢數(shù)據(jù)
deleteTable();//刪除表
closeConnection();//關(guān)閉連接
System.out.println(“---------------??結(jié)束!????-----------------“);
}?catch?(Exception?e)?{
e.printStackTrace();
}
}

/**
?*?初始化
?*?@throws?Exception
?*/
public?static?void?setup()?throws?Exception{
System.out.println(“---------------??開(kāi)始初始化??-----------------“);

//取得一個(gè)數(shù)據(jù)庫(kù)連接的配置參數(shù)對(duì)象
Configuration?conf?=?HbaseConfiguration.create();
//設(shè)置連接參數(shù):Hbase數(shù)據(jù)庫(kù)所在的主機(jī)IP
conf.set(“hbase.zookeeper.quorum“?“datanode1datanode2datanode3“);
//設(shè)置連接參數(shù):Hbase數(shù)據(jù)庫(kù)使用的端口
conf.set(“hbase.zookeeper.property.clientPort“?“2181“);
// conf.set(“hbase.master“?“manager:16000“);
conf.set(“hbase.master.port“?“16000“);
conf.set(“hbase.zookeeper.useMulti“?“true“);
conf.set(“hbase.regionserver.info.port“?“16030“);
conf.set(“hbase.regionserver.port“?“16020“);
conf.set(“zookeeper.znode.parent“?“/hbase-unsecure“);

//取得一個(gè)數(shù)據(jù)庫(kù)連接對(duì)象
conn=ConnectionFactory.createConnection(conf);
//取得一個(gè)數(shù)據(jù)庫(kù)元數(shù)據(jù)操作對(duì)象
admin=conn.getAdmin();

System.out.println(“---------------??初始化完成???-----------------“);
}

/**
?*?創(chuàng)建表
?*?@throws?Exception
?*/
public?static?void?createTable()throws?Exception{
System.out.println(“---------------創(chuàng)建表?START-----------------“);

//創(chuàng)建namespace?
admin.createNamespace(NamespaceDescriptor.create(“WHG“).build());

//?數(shù)據(jù)表表名
String?tableName=“WHG:TB1“;

//?新建一個(gè)數(shù)據(jù)表表名對(duì)象
TableName?tn?=?TableName.valueOf(tableName);

//判斷表是否存在
if(admin.tableExists(tn)){
System.out.println(tableName+“表已經(jīng)存在!“);
}else{
System.out.println(tableName+“表不存在,開(kāi)始

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????8230??2018-11-27?16:05??.classpath
?????文件?????????385??2018-11-27?16:04??.project
?????目錄???????????0??2018-11-27?16:04??.settings\
?????文件?????????598??2018-11-27?16:04??.settings\org.eclipse.jdt.core.prefs
?????目錄???????????0??2018-11-27?16:05??bin\
?????目錄???????????0??2018-11-27?16:05??bin\whg\
?????目錄???????????0??2018-11-27?16:05??bin\whg\hbase\
?????文件????????7757??2018-11-27?16:05??bin\whg\hbase\HbaseCRUD.class
?????目錄???????????0??2018-11-27?16:05??lib\
?????文件???????62983??2018-03-09?15:28??lib\activation-1.1.jar
?????文件???????71717??2018-03-09?15:28??lib\antisamy-1.4.3.jar
?????文件????????4467??2018-03-09?15:28??lib\aopalliance-1.0.jar
?????文件???????44925??2018-03-09?15:28??lib\apacheds-i18n-2.0.0-M15.jar
?????文件??????691479??2018-03-09?15:28??lib\apacheds-kerberos-codec-2.0.0-M15.jar
?????文件???????16560??2018-03-09?15:28??lib\api-asn1-api-1.0.0-M20.jar
?????文件???????79912??2018-03-09?15:28??lib\api-util-1.0.0-M20.jar
?????文件???????43033??2018-03-09?15:28??lib\asm-3.1.jar
?????文件??????303139??2018-03-09?15:28??lib\avro-1.7.4.jar
?????文件??????317060??2018-03-09?15:28??lib\batik-css-1.7.jar
?????文件???????10267??2018-03-09?15:28??lib\batik-ext-1.7.jar
?????文件??????130304??2018-03-09?15:28??lib\batik-util-1.7.jar
?????文件??????143992??2018-03-09?15:28??lib\bsh-core-2.0b4.jar
?????文件??????188671??2018-03-09?15:28??lib\commons-beanutils-1.7.0.jar
?????文件??????168760??2018-03-09?15:28??lib\commons-beanutils-core-1.7.0.jar
?????文件???????41123??2018-03-09?15:28??lib\commons-cli-1.2.jar
?????文件??????263965??2018-03-09?15:28??lib\commons-codec-1.9.jar
?????文件??????588337??2018-03-09?15:28??lib\commons-collections-3.2.2.jar
?????文件??????241367??2018-03-09?15:28??lib\commons-compress-1.4.1.jar
?????文件??????298829??2018-03-09?15:28??lib\commons-configuration-1.6.jar
?????文件???????24239??2018-03-09?15:28??lib\commons-daemon-1.0.13.jar
?????文件??????143602??2018-03-09?15:28??lib\commons-digester-1.8.jar
............此處省略103個(gè)文件信息

評(píng)論

共有 條評(píng)論

相關(guān)資源