這篇文章主要介紹HBase JAVA API怎么用,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
成都創(chuàng)新互聯(lián)主要從事做網(wǎng)站、網(wǎng)站制作、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)中方,10余年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來(lái)電咨詢建站服務(wù):18982081108
pom.xml
org.apache.hbase hbase-client 1.3.5 org.apache.hbase hbase-server 1.3.5
靜態(tài)代碼塊
private static Connection connection = null; private static Admin admin = null;; static { try { Configuration configuration = HBaseConfiguration.create(); configuration.set("hbase.zookeeper.quorum", "aliyun:2181"); connection = ConnectionFactory.createConnection(configuration); admin = connection.getAdmin(); } catch (IOException e) { e.printStackTrace(); } }
//創(chuàng)建表 public static void createTable(String tableName, String[] cols) throws IOException { TableName table = TableName.valueOf(tableName); if (admin.tableExists(table)) { System.out.println("表已存在!"); } else { HTableDescriptor hTableDescriptor = new HTableDescriptor(tableName); for (String col : cols) { HColumnDescriptor hColumnDescriptor = new HColumnDescriptor(col); hTableDescriptor.addFamily(hColumnDescriptor); } try { admin.createTable(hTableDescriptor); } catch (IOException e) { e.printStackTrace(); } } }
以上是“HBase JAVA API怎么用”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!