Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ Java to create a table in the database SYBase     - MySQL binlog group to submit XA (two-phase commit) (Database)

- Improve the Ubuntu SSH login authentication approach speed (Linux)

- Linux linux system security (Linux)

- shell script: MySQL startup script simple (Database)

- Binary tree and some basic operations with binary list (Programming)

- Binary tree to the next node (Programming)

- Ubuntu Backup and Recovery (Linux)

- CentOS system Amoeba + MySQL Master-slave configuration (Database)

- SQL MySQL query table duplicate data (Database)

- The official release method to upgrade to Ubuntu 15.04 (Linux)

- xCAT install and update software (Linux)

- Linux system started to learn: Teaches you install Ubuntu 15.04 on VirtualBox (Linux)

- Simple and fast sorting (Programming)

- Linux find command usage practices (Linux)

- Compression software on a simple comparison of zip and gz (Linux)

- APR for Tomcat installation under Linux (Server)

- Ubuntu 14.04 and derivative version of the user on how to install cURL 7.37.1 (Linux)

- About ORA-02391 solution (Database)

- Linux commands with browsing and downloading files (Linux)

- CentOS 6.5 boot automatically mount the hard drive (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> 1.1.0.1 < / 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", "127.0.0.1");
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", "127.0.0.1");
        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 ();
            }
        }
    }
}
     
         
         
         
  More:      
 
- CentOS yum source configuration (Linux)
- Making Linux root file system problems on-link library (Programming)
- Linux environment variable configuration and save places (Linux)
- Computer security perimeter recommendations (Linux)
- Install Rubinius testing Ubuntu 14.04 native threads (Linux)
- MongoDB configuration in Ubuntu 14.04 (Database)
- How to install the NVIDIA 358.16 driver in Ubuntu 15.10,14.04 (Linux)
- Linux firewall iptables beginner tutorial (Linux)
- Linux SSH login without a password (Linux)
- APF firewall installation and configuration under Linux (Linux)
- Linux Thread Synchronization (Programming)
- Let MySQL 5.6 support Emoji expression (Database)
- Linux kernel update error, update-initramfs: failed Solution (Linux)
- Can not remember how to solve the problem under Ubuntu brightness setting (Linux)
- Mumble installation source VoIP application on Ubuntu (Linux)
- Getting Started with Linux system to learn: how to check memory usage of Linux (Linux)
- Ansible module Know (Linux)
- CentOS7 virtual machine starts appear Permission denied (Linux)
- Manually create Oracle Database Explanations (Database)
- Configuring s3c-linux-2.6.28.6-Real6410 appears Unable to find the QT3 installation (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.