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.io.IOException;
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("hbase.zookeeper.property.clientPort", "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);
 gets.add(get1);

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

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

 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,280 points
132 views

1 answer to this question.

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
• 69,020 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
• 13,180 points
161 views
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
• 2,050 points
171 views
0 votes
1 answer

Getting error while using sqoop import.

You are trying to execute the sqoop ...READ MORE

answered Jul 5, 2019 in Big Data Hadoop by Reshma
145 views
0 votes
1 answer

PIG Error while loading file: -bash: syntax error near unexpected token `('

Since your data is delimited with tabs ...READ MORE

answered Jul 31, 2019 in Big Data Hadoop by Ritu
550 views
0 votes
1 answer
+1 vote
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
• 10,920 points
5,517 views
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
• 10,920 points
814 views
+1 vote
11 answers

hadoop fs -put command?

put syntax: put <localSrc> <dest> copy syntax: copyF ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Aditya
34,212 views
0 votes
1 answer

Error while connecting to Hive using Java JDBC

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

answered Nov 21, 2018 in Big Data Hadoop by Omkar
• 69,020 points
485 views
0 votes
1 answer

Getting error while loading data into hive table

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

answered Jan 30, 2019 in Big Data Hadoop by Omkar
• 69,020 points
699 views