Getting some warning/error while loading java file using Hbase commands

0 votes

I am trying to load java file using HBase commands. This is my java code: 

package hbase;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;

import java.util.ArrayList;
import java.util.List;

public class GetListExample {

 public static void main(String[] args) throws IOException {
Configuration conf = HBaseConfiguration.create();
 conf.set("hbase.zookeeper.quorum", "ip-20-0-31-249.ec2.internal");
conf.set("", "2181");
 HTable table = new HTable(conf, "customers");

 // GetListExample
 byte[] cf1 = Bytes.toBytes("info");
 byte[] qf1 = Bytes.toBytes("fname");
 byte[] qf2 = Bytes.toBytes("lname");
 byte[] row1 = Bytes.toBytes("4005000");
 byte[] row2 = Bytes.toBytes("4009000");

List<Get> gets = new ArrayList<Get>();

 Get get1 = new Get(row1);
 get1.addColumn(cf1, qf1);

 Get get2 = new Get(row2);
 get2.addColumn(cf1, qf1);

 Get get3 = new Get(row2);
 get3.addColumn(cf1, qf2);

 Result[] results = table.get(gets); 

 System.out.println("First iteration...");
 for (Result result : results) {
 String row = Bytes.toString(result.getRow());
 System.out.print("Row: " + row + " ");
 byte[] val = null;
 if (result.containsColumn(cf1, qf1)) {
 val = result.getValue(cf1, qf1);
 System.out.println("Value: " + Bytes.toString(val));
 if (result.containsColumn(cf1, qf2)) {
 val = result.getValue(cf1, qf2);
 System.out.println("Value: " + Bytes.toString(val));
 System.out.println("Second iteration...");
 for (Result result : results) {
 for (KeyValue kv : result.raw()) {
 System.out.println("Row: " + Bytes.toString(kv.getRow()) +
 " Value: " + Bytes.toString(kv.getValue()));
 // GetListExample

When I try to load it, I get could not find or load main class error. How to solve this?

Dec 14, 2018 in Big Data Hadoop by slayer
• 29,040 points

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

In your code, you have set some configurations for hbase. You have set port number and ip address. This port number and ip address should be the same as mentioned in the configuration file. So what you do is, open the hbase-site.xml and check the port number and ip address. Use that ip address and port number in your code. It should work

answered Dec 14, 2018 by Omkar
• 65,850 points

Related Questions In Big Data Hadoop

+3 votes
1 answer

Getting Connection Error while loading data into table using cloudera hive

Hey Nafeesa, Itseems that Hive is not able ...READ MORE

answered Oct 3, 2018 in Big Data Hadoop by Vardhan
• 10,620 points
0 votes
1 answer

Getting error while building Hadoop core jar using ant.

I think you are missing libtool library. ...READ MORE

answered Apr 18, 2018 in Big Data Hadoop by coldcode
• 1,980 points
+1 vote
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 9,070 points
0 votes
1 answer

hadoop.mapred vs hadoop.mapreduce?

org.apache.hadoop.mapred is the Old API  org.apache.hadoop.mapreduce is the ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 9,070 points
0 votes
10 answers

hadoop fs -put command?

copy command can be used to copy files ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Sujay
0 votes
1 answer

Error while connecting to Hive using Java JDBC

Use ​org.apache.hive.jdbc.HiveDriver as your driver. It ...READ MORE

answered Nov 21, 2018 in Big Data Hadoop by Omkar
• 65,850 points
0 votes
1 answer

Getting error while loading data into hive table

In the command you have used, the ...READ MORE

answered Jan 30 in Big Data Hadoop by Omkar
• 65,850 points

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.