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,370 points
880 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,220 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 4, 2018 in Big Data Hadoop by Vardhan
• 13,150 points
1,022 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,090 points
1,007 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
1,445 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
2,084 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
• 11,380 points
11,077 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
• 11,380 points
2,574 views
+2 votes
11 answers

hadoop fs -put command?

Hi, You can create one directory in HDFS ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by nitinrawat895
• 11,380 points
109,071 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 22, 2018 in Big Data Hadoop by Omkar
• 69,220 points
1,873 views
0 votes
1 answer

Getting error while loading data into hive table

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

answered Jan 31, 2019 in Big Data Hadoop by Omkar
• 69,220 points
3,400 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP