Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ Java to create a table in the database SYBase     - Virtual Judge environment to build and configure under Ubuntu (Server)

- DataGuard Standby backup error RMAN-06820 ORA-17629 to solve (Database)

- Nginx multi-domain certificate HTTPS (Server)

- ISO image to use offline upgrade Ubuntu (Linux)

- Linux IPTables anti-DDOS attack Shell Scripting (Linux)

- MySQL master-slave database configuration and error handling Raiders (Database)

- Android in the event delivery and handling mechanism (Programming)

- Let CentOS6 yum upgrade to support more source rpm package (Linux)

- MySQL uses mysqld_multi to deploy stand-alone multi-instance detail procedures (Database)

- Create your own YUM repository (Linux)

- Several Ceph performance optimization of new methods and ideas (2015 SH Ceph Day after flu reference) (Server)

- Linux processes in memory and memory cgroup statistics (Linux)

- Node.js simple interface server (Server)

- xCAT error Unable to dispatch hierarchical sub-command to NORESOLUTION: 3001 (Linux)

- Use libcurl library download url image (Programming)

- C ++ string in the end (Programming)

- Linux System Getting Started Tutorial: how to find information on Linux-embedded module (Linux)

- Linux Programming memory mapping (Programming)

- Git bulk delete remote tag (Linux)

- MySQL master recovery from failure using binlog (Database)

 
         
  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:      
 
- Oracle 11g statistics collection - collection of multi-column statistics (Database)
- Use the dd command to the hard disk I / O performance test (Linux)
- Physical structure and process disk IO (Linux)
- Install Kali Linux via PXE network (Linux)
- Each catalog Detailed Linux (Linux)
- Database Blob data type conversion String (Programming)
- VMware virtual machine to install CentOS 6.2 (Linux)
- Java Foundation - Getting Start (Programming)
- Java implementation chain store binary search tree (recursive method) (Programming)
- Analysis of Java reflection mechanism (Programming)
- How to configure MariaDB replication in CentOS Linux (Database)
- Search Linux commands and files - which, whereis, locate, find (Linux)
- Installation and operation GAMIT software under Linux operating system (Linux)
- CentOS permanently banned from running in the background PackageKit (Linux)
- Python dictionary applications get built-in method (Programming)
- MongoDB 3.0 New Features (Database)
- CentOS 7.0 Enable iptables firewall (Linux)
- Ubuntu 14.04 compile RT288x_SDK / toolchain / squashfs3.2-r2 Error (Linux)
- Tor Browser: under Linux for anonymous Web browsing ultimate browser (Linux)
- SolrCloud-5.2.1 cluster deployment and testing (Server)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.