Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Database \ Java to create a table in the database SYBase     - React Getting Started Tutorial (Linux)

- Differences Shell scripting languages and compiled languages (Programming)

- Build your own CA services: OpenSSL command line CA Quick Guide (Server)

- Ubuntu system cp: omitting directory problem (Linux)

- Shared directory settings between Linux and Linux (Linux)

- Recover Ubuntu 14.04 wakes up from standby in case mouse keyboard appears dead (Linux)

- On the PC goes heavy security watch your startup items (Linux)

- Java-based data source database access (Programming)

- Nagios (centreon) monitoring LVS (Server)

- Use matplotlib scientific drawing in Linux (Linux)

- PostgreSQL export table structure information (Database)

- Oracle database on the hit rate of query summary (Database)

- Linux Shell debugging (Programming)

- ACL permissions Linux command (Linux)

- Nginx + uWSGI + Django + Python Application Architecture Deployment (Server)

- Ubuntu use three methods to install Ruby (Linux)

- The practical application of Oracle synonyms + dblink (Database)

- Android Delete project useless resource file (Programming)

- crontab task scheduling Health Check (Linux)

- linux firewall configuration (Linux)

  Java to create a table in the database SYBase
  Add Date : 2018-11-21      
  To create a data table in HBase by Java, you first need to import hbase-client.jar driver package. You can add dependencies in the project pom.xml configuration file:

< Dependency>
     < GroupId> org.apache.hbase < / groupId>
     < ArtifactId> hbase-client < artifactId>
     < Version> < / version>
< Dependency>
After adding a dependency, we need to create a Configuration object and specify core-site.xml and hbase-site.xml as a resource file.

Configuration config = HBaseConfiguration.create ();
config.addResource (new Path ( "/ etc / hbase / conf / hbase-site.xml"));
config.addResource (new Path ( "/ etc / Hadoop / conf / core-site.xml"));
Also need to set parameters and values ​​hbase.zookeeper.quorum hbase.zookeeper.property.clientPort parameters in the Configuration object, these values ​​can also be found in hbase-site.xml configuration file:

Configuration config = HBaseConfiguration.create ();
config.set ( "hbase.zookeeper.quorum", "");
config.set ( "hbase.zookeeper.property.clientPort", "2181");
After the Configuration object is created, and then create a connection to the Connection object HBase database, and get Admin objects of this object, it is responsible for implementing the creation of data tables:

Connection connection = ConnectionFactory.createConnection (config);
Admin admin = connection.getAdmin ();
Once you have created the Admin object can use the following code to create a data table:

String tableName = "users";

if (! admin.isTableAvailable (TableName.valueOf (tableName))) {
    HTableDescriptor hbaseTable = new HTableDescriptor (TableName.valueOf (tableName));
    hbaseTable.addFamily (new HColumnDescriptor ( "name"));
    hbaseTable.addFamily (new HColumnDescriptor ( "contact_info"));
    hbaseTable.addFamily (new HColumnDescriptor ( "personal_info"));
    admin.createTable (hbaseTable);
Whether there will be serious "users" name of the data table, if the table does not exist will create a new table, column names include: family name, contact information and personal information.

Complete the following procedures:

package com.wordpress.khodeprasad;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
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;

/ **
* @author Prasad Khode
* /
public class CreateTable {

    public static void main (String [] args) {
        CreateTable object = new CreateTable ();
        object.createTable ();

    public void createTable () {
        Configuration config = HBaseConfiguration.create ();
        config.set ( "hbase.zookeeper.quorum", "");
        config.set ( "hbase.zookeeper.property.clientPort", "2181");

        Connection connection = null;
        Admin admin = null;

        try {
            connection = ConnectionFactory.createConnection (config);
            admin = connection.getAdmin ();

            String tableName = "users";

            if (! admin.isTableAvailable (TableName.valueOf (tableName))) {
                HTableDescriptor hbaseTable = new HTableDescriptor (TableName.valueOf (tableName));
                hbaseTable.addFamily (new HColumnDescriptor ( "name"));
                hbaseTable.addFamily (new HColumnDescriptor ( "contact_info"));
                hbaseTable.addFamily (new HColumnDescriptor ( "personal_info"));
                admin.createTable (hbaseTable);
        } Catch (Exception e) {
            e.printStackTrace ();
        } Finally {
            try {
                if (admin! = null) {
                    admin.close ();

                if (connection! = null &&! connection.isClosed ()) {
                    connection.close ();
            } Catch (Exception e2) {
                e2.printStackTrace ();
- Java implementation linear table - represents the order of representation and chain (Programming)
- The new features of MySQL 5.7 Generated Column (index function) (Database)
- How to install Bugzilla 4.4 on Ubuntu / CentOS 6.x (Linux)
- Java MD5 encryption implementation (Programming)
- Linux file system structure Introduction (Linux)
- Oracle Database Restore (Database)
- Linux firewall settings instance (Linux)
- Debian 8.2.0 (Jessie) fast clean installation tutorial (Linux)
- MySQL and Oracle time zone settings compare (Database)
- vnStatSVG: traffic monitoring software vnStat (Linux)
- HTML5 Fundamentals study notes (Programming)
- RHEL 5.7 Yum configure local source [Errno 2] No such file or directory (Linux)
- swap space is insufficient cause OOM kill MySQL Case (Database)
- Recovery from MySQL master data consistency summary (Database)
- SSH Filesystem use a secure connection for network file system (Linux)
- Linux Getting Started tutorial: XWindow what (Linux)
- Linux System Getting Started Learning: DeVeDe installed on Linux to create a video DVD (Linux)
- Hadoop 2.7.1 Installation and Configuration under RedHat Linux 6.5 (Server)
- Linux command line under HTTP traffic sniffing tool: httpry (Linux)
- Docker container plaintext password problem-solving way (Server)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.