Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Database \ Java to create a table in the database SYBase     - Linux file permissions to modify the command: chmod (Linux)

- 10 Best Swift Tutorial examples (Programming)

- Struts2 configure a static resource files without Struts processing (regular match) (Programming)

- Java NIO2: Buffer (Programming)

- Kernel compile under Debian (Linux)

- Simple to use multi-threaded programming under Linux mutex and condition variable (Programming)

- Win8 mount disk partitions under Ubuntu (Linux)

- CentOS7 installation performance monitoring system (Server)

- Distributed Hadoop1.2.1 cluster installation (Server)

- What is Java EE (Programming)

- Linux System Getting Started Tutorial: How to Force Change your password at next logon Linux (Linux)

- Ubuntu install VMware Workstation 11 tutorials at 14.04 / 14.10 (Linux)

- Mac OS X 10.9 compiler OCI8 module (Programming)

- To upgrade combat MongoDB database replication sets and split versions (Database)

- Fedora 8 configured Heartbeat (Linux)

- Android thread mechanism --AsyncTask (Programming)

- Configure shared library PCRE (Linux)

- Learn to read the source code of vmstat (Linux)

- Xtrabackup creates a slave node without downtime (Database)

- Linux, Apache Web site security settings (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 ();
- Dalvik heap memory management and recycling (Linux)
- Tmux create the perfect terminal management tool under CentOS (Linux)
- Security matters and practical Linux System (Linux)
- Under CentOS yum install Nginx smooth switch mounted to Tengine (Server)
- After the first remote installation GlassFish Web to remotely access their back office management system error solution appears (Server)
- Linux System Getting Started Learning: install software packages on Ubuntu and Fedora (Linux)
- How to add two-factor authentication for Linux systems SSH (Linux)
- Linux / Centos anti CC attack script (Linux)
- sudo command scenario analysis (Linux)
- RabbitMQ tutorial examples: RabbitMQ installation under Windows (Linux)
- Ubuntu and derivative system users how to install Pinta 1.5 (Linux)
- After reloading the cinder-volume OpenStack not start properly (Server)
- SUSE Firewall Configuration (Linux)
- CentOS 6.5 boot automatically mount the hard drive (Linux)
- Build Golang development environment configuration on Ubuntu 14.04 (Linux)
- Use SecureCRT to transfer files between Linux and Windows (Linux)
- ARM Linux system call (Linux)
- MongoDB 3.0 New Features (Database)
- I like Linux Security (Linux)
- Oracle archive log full cause abnormal slow database performance (Database)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.