/*** @Title: queryData
* @Description: 从HBase查询出数据
*@authorxxxx
*@paramtableName
* 表名
*@paramrowkey
* rowkey
*@return返回用户信息的list
*@throwsIOException
*@throwsUnsupportedEncodingException*/
public static ArrayListqueryData(String tableName,
String rowkey)throwsIOException, UnsupportedEncodingException
{
ArrayList list = new ArrayList();
Configuration config=SignHBase.getConfiguration();
HTable table= newHTable(config, tableName);
Get get= new Get(rowkey.getBytes()); //根据主键查询
Result r =table.get(get);
KeyValue[] kv=r.raw();
xxxxUserInfo xxxxUserInfo= newxxxxUserInfo();for (int i = 0; i < kv.length; i++)
{//循环每一列
String qualifier = newString(kv[i].getQualifier());if (qualifier.equals("n"))
{
String val= newString(kv[i].getValue());
xxxxUserInfo.setName(val);
}else if (qualifier.equals("b"))
{
String val= newString(kv[i].getValue());
xxxxUserInfo.setBirthday(val);
}else if (qualifier.equals("a"))
{
String val= newString(kv[i].getValue());
xxxxUserInfo.setAddress(val);
}else if (qualifier.equals("z"))
{
String val= newString(kv[i].getValue());
xxxxUserInfo.setZip(val);
}else if (qualifier.equals("f"))
{
String val= newString(kv[i].getValue());
xxxxUserInfo.setFax(val);
}else if (qualifier.equals("cid"))
{
String val= newString(kv[i].getValue());
xxxxUserInfo.setCtfid(val);
}else if (qualifier.equals("m"))
{
String val= newString(kv[i].getValue());
xxxxUserInfo.setMobile(val);
}else if (qualifier.equals("t"))
{
String val= newString(kv[i].getValue());
xxxxUserInfo.setTel(val);
}else if (qualifier.equals("e"))
{
String val= newString(kv[i].getValue());
xxxxUserInfo.setEmail(val);
}else if (qualifier.equals("g"))
{
String val= newString(kv[i].getValue());
xxxxUserInfo.setGender(val);
}else if (qualifier.equals("n"))
{
String val= newString(kv[i].getValue());
xxxxUserInfo.setNationality(val);
}else if (qualifier.equals("ct"))
{
String val= newString(kv[i].getValue());
xxxxUserInfo.setCtftp(val);
}
}//end of 遍历每一列
list.add(xxxxUserInfo);//将查询到的结果写入List中
returnlist;
}