求助?eclipse連接hbase出現如下異常

eclipse 連接hbase

異常爲:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/apache/hbase/hbase-0.92.1/hbase-0.92.1/lib/slf4j-log4j12-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/apache/hadoop/hadoop-1.0.0/hadoop-1.0.0/lib/slf4j-log4j12-1.4.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
12/05/28 15:58:22 INFO zookeeper.ZooKeeper: Client environment:zookeeper.version=3.4.3-1240972, built on 02/06/2012 10:48 GMT
12/05/28 15:58:22 INFO zookeeper.ZooKeeper: Client environment:host.name=49.123.83.105
12/05/28 15:58:22 INFO zookeeper.ZooKeeper: Client environment:java.version=1.6.0_22
12/05/28 15:58:22 INFO zookeeper.ZooKeeper: Client environment:java.vendor=Sun Microsystems Inc.
12/05/28 15:58:22 INFO zookeeper.ZooKeeper: Client environment:java.home=C:\myProgramFiles\JAVA\jdk1.6\jre
12/05/28 15:58:22 INFO zookeeper.ZooKeeper: Client environment:java.class.path=D:\workSpace\eclipse3.3.001_WorkSpace\HBaseClient\bin;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\hbase-0.92.1.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\hbase-0.92.1-tests.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\activation-1.1.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\asm-3.1.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\avro-1.5.3.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\avro-ipc-1.5.3.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\commons-beanutils-1.7.0.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\commons-beanutils-core-1.8.0.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\commons-cli-1.2.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\commons-codec-1.4.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\commons-collections-3.2.1.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\commons-configuration-1.6.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\commons-digester-1.8.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\commons-el-1.0.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\commons-httpclient-3.1.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\commons-lang-2.5.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\commons-logging-1.1.1.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\commons-math-2.1.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\commons-net-1.4.1.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\core-3.1.1.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\guava-r09.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\hadoop-core-1.0.0.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\high-scale-lib-1.1.1.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\httpclient-4.0.1.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\httpcore-4.0.1.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\jackson-core-asl-1.5.5.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\jackson-jaxrs-1.5.5.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\jackson-mapper-asl-1.5.5.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\jackson-xc-1.5.5.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\jamon-runtime-2.3.1.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\jasper-compiler-5.5.23.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\jasper-runtime-5.5.23.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\jaxb-api-2.1.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\jaxb-impl-2.1.12.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\jersey-core-1.4.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\jersey-json-1.4.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\jersey-server-1.4.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\jettison-1.1.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\jetty-6.1.26.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\jetty-util-6.1.26.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\jruby-complete-1.6.5.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\jsp-2.1-6.1.14.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\jsp-api-2.1-6.1.14.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\libthrift-0.7.0.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\log4j-1.2.16.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\netty-3.2.4.Final.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\protobuf-java-2.4.0a.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\servlet-api-2.5.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\servlet-api-2.5-6.1.14.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\slf4j-api-1.5.8.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\slf4j-log4j12-1.5.8.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\snappy-java-1.0.3.2.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\stax-api-1.0.1.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\velocity-1.7.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\xmlenc-0.52.jar;D:\apache\hbase\hbase-0.92.1\hbase-0.92.1\lib\zookeeper-3.4.3.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\asm-3.2.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\aspectjrt-1.6.5.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\aspectjtools-1.6.5.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\commons-beanutils-1.7.0.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\commons-beanutils-core-1.8.0.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\commons-cli-1.2.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\commons-codec-1.4.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\commons-collections-3.2.1.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\commons-configuration-1.6.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\commons-daemon-1.0.1.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\commons-digester-1.8.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\commons-el-1.0.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\commons-httpclient-3.0.1.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\commons-lang-2.4.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\commons-logging-1.1.1.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\commons-logging-api-1.0.4.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\commons-math-2.1.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\commons-net-1.4.1.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\core-3.1.1.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\hadoop-capacity-scheduler-1.0.0.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\hadoop-fairscheduler-1.0.0.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\hadoop-thriftfs-1.0.0.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\hsqldb-1.8.0.10.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\jackson-core-asl-1.0.1.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\jackson-mapper-asl-1.0.1.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\jasper-compiler-5.5.12.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\jasper-runtime-5.5.12.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\jdeb-0.8.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\jersey-core-1.8.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\jersey-json-1.8.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\jersey-server-1.8.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\jets3t-0.6.1.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\jetty-6.1.26.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\jetty-util-6.1.26.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\jsch-0.1.42.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\junit-4.5.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\kfs-0.2.2.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\log4j-1.2.15.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\mockito-all-1.8.5.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\oro-2.0.8.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\servlet-api-2.5-20081211.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\slf4j-api-1.4.3.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\slf4j-log4j12-1.4.3.jar;D:\apache\hadoop\hadoop-1.0.0\hadoop-1.0.0\lib\xmlenc-0.52.jar
12/05/28 15:58:22 INFO zookeeper.ZooKeeper: Client environment:java.library.path=C:\myProgramFiles\JAVA\jdk1.6\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\myProgramFiles\JAVA\jdk1.6\bin\..\jre\bin\client;C:\myProgramFiles\JAVA\jdk1.6\bin\..\jre\bin;C:\Program Files\Common Files\NetSarang;C:\myProgramFiles\JAVA\jdk1.6\bin;C:\MinGW\bin;C:\oracle\oracle10\bin;C:\cygwin\bin;C:\cygwin\usr\sbin;D:\apache\ant\apache-ant-1.8.3-bin\apache-ant-1.8.3\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\SSH Communications Security\SSH Secure Shell
12/05/28 15:58:22 INFO zookeeper.ZooKeeper: Client environment:java.io.tmpdir=C:\Users\myq\AppData\Local\Temp\
12/05/28 15:58:22 INFO zookeeper.ZooKeeper: Client environment:java.compiler=<NA>
12/05/28 15:58:22 INFO zookeeper.ZooKeeper: Client environment:os.name=Windows 7
12/05/28 15:58:22 INFO zookeeper.ZooKeeper: Client environment:os.arch=x86
12/05/28 15:58:22 INFO zookeeper.ZooKeeper: Client environment:os.version=6.1
12/05/28 15:58:22 INFO zookeeper.ZooKeeper: Client environment:user.name=myq
12/05/28 15:58:22 INFO zookeeper.ZooKeeper: Client environment:user.home=C:\Users\myq
12/05/28 15:58:22 INFO zookeeper.ZooKeeper: Client environment:user.dir=D:\workSpace\eclipse3.3.001_WorkSpace\HBaseClient
12/05/28 15:58:22 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=hadoop-node7:2181,hadoop-node6:2181,hadoop-node8:2181 sessionTimeout=180000 watcher=hconnection
12/05/28 15:58:22 INFO zookeeper.ClientCnxn: Opening socket connection to server /216.34.94.184:2181
12/05/28 15:58:22 INFO zookeeper.RecoverableZooKeeper: The identifier of this process is 34096@myq-PC
12/05/28 15:58:22 WARN client.ZooKeeperSaslClient: SecurityException: java.lang.SecurityException: 無法定位登錄配置 occurred when trying to find JAAS configuration.
12/05/28 15:58:22 INFO client.ZooKeeperSaslClient: Client will not SASL-authenticate because the default JAAS configuration section 'Client' could not be found. If you are not using SASL, you may ignore this. On the other hand, if you expected SASL to work, please fix your JAAS configuration.
12/05/28 15:58:43 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection timed out: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:574)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:286)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1035)
12/05/28 15:58:43 INFO zookeeper.ClientCnxn: Opening socket connection to server /216.34.94.184:2181
12/05/28 15:58:43 WARN client.ZooKeeperSaslClient: SecurityException: java.lang.SecurityException: 無法定位登錄配置 occurred when trying to find JAAS configuration.
12/05/28 15:58:43 INFO client.ZooKeeperSaslClient: Client will not SASL-authenticate because the default JAAS configuration section 'Client' could not be found. If you are not using SASL, you may ignore this. On the other hand, if you expected SASL to work, please fix your JAAS configuration.
12/05/28 15:58:43 WARN zookeeper.RecoverableZooKeeper: Possibly transient ZooKeeper exception: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/master
12/05/28 15:58:43 INFO util.RetryCounter: The 1 times to retry  after sleeping 2000 ms
12/05/28 15:59:04 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection timed out: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:574)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:286)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1035)
12/05/28 15:59:04 INFO zookeeper.ClientCnxn: Opening socket connection to server /49.123.83.8:2181
12/05/28 15:59:04 WARN zookeeper.RecoverableZooKeeper: Possibly transient ZooKeeper exception: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/master
12/05/28 15:59:04 INFO util.RetryCounter: The 2 times to retry  after sleeping 4000 ms
12/05/28 15:59:04 WARN client.ZooKeeperSaslClient: SecurityException: java.lang.SecurityException: 無法定位登錄配置 occurred when trying to find JAAS configuration.
12/05/28 15:59:04 INFO client.ZooKeeperSaslClient: Client will not SASL-authenticate because the default JAAS configuration section 'Client' could not be found. If you are not using SASL, you may ignore this. On the other hand, if you expected SASL to work, please fix your JAAS configuration.
12/05/28 15:59:04 INFO zookeeper.ClientCnxn: Socket connection established to hadoop-node8/49.123.83.8:2181, initiating session
12/05/28 15:59:04 WARN zookeeper.ClientCnxnSocket: Connected to an old server; r-o mode will be unavailable
12/05/28 15:59:04 INFO zookeeper.ClientCnxn: Session establishment complete on server hadoop-node8/49.123.83.8:2181, sessionid = 0x337917258a80002, negotiated timeout = 40000
12/05/28 15:59:08 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=hadoop-node7:2181,hadoop-node6:2181,hadoop-node8:2181 sessionTimeout=180000 watcher=catalogtracker-on-org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@19b5217
12/05/28 15:59:08 INFO zookeeper.ClientCnxn: Opening socket connection to server /49.123.83.8:2181
12/05/28 15:59:08 WARN client.ZooKeeperSaslClient: SecurityException: java.lang.SecurityException: 無法定位登錄配置 occurred when trying to find JAAS configuration.
12/05/28 15:59:08 INFO client.ZooKeeperSaslClient: Client will not SASL-authenticate because the default JAAS configuration section 'Client' could not be found. If you are not using SASL, you may ignore this. On the other hand, if you expected SASL to work, please fix your JAAS configuration.
12/05/28 15:59:08 INFO zookeeper.RecoverableZooKeeper: The identifier of this process is 34096@myq-PC
12/05/28 15:59:08 INFO zookeeper.ClientCnxn: Socket connection established to hadoop-node8/49.123.83.8:2181, initiating session
12/05/28 15:59:08 WARN zookeeper.ClientCnxnSocket: Connected to an old server; r-o mode will be unavailable
12/05/28 15:59:08 INFO zookeeper.ClientCnxn: Session establishment complete on server hadoop-node8/49.123.83.8:2181, sessionid = 0x337917258a80003, negotiated timeout = 40000
12/05/28 15:59:28 INFO ipc.HBaseRPC: Problem connecting to server: hadoop-node6/216.34.94.184:60020



下面是測試小程序:



import java.io.IOException;
import java.util.ArrayList;
import java.util.List;


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.KeyValue;
import org.apache.hadoop.hbase.MasterNotRunningException;
import org.apache.hadoop.hbase.ZooKeeperConnectionException;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.util.Bytes;


public class Test001 {


private static Configuration conf = null;
/**
* 初始化配置
*/
static {
conf = HBaseConfiguration.create();
}


/**
* 創建表操作
* @throws IOException
*/
public void createTable(String tablename, String[] cfs) throws IOException {
HBaseAdmin admin = new HBaseAdmin(conf);
if (admin.tableExists(tablename)) {
System.out.println("表已經存在!");
} else {
HTableDescriptor tableDesc = new HTableDescriptor(tablename);
for (int i = 0; i < cfs.length; i++) {
tableDesc.addFamily(new HColumnDescriptor(cfs[i]));
}
admin.createTable(tableDesc);
System.out.println("表創建成功!");
}
}


/**
* 刪除表操作
* @param tablename
* @throws IOException
*/
public void deleteTable(String tablename) throws IOException {
try {
HBaseAdmin admin = new HBaseAdmin(conf);
admin.disableTable(tablename);
admin.deleteTable(tablename);
System.out.println("表刪除成功!");
} catch (MasterNotRunningException e) {
e.printStackTrace();
} catch (ZooKeeperConnectionException e) {
e.printStackTrace();
}
}


/**
* 插入一行記錄
* @param tablename
* @param cfs
*/
public void writeRow(String tablename, String[] cfs) {
try {
HTable table = new HTable(conf, tablename);
Put put = new Put(Bytes.toBytes("rows1"));
for (int j = 0; j < cfs.length; j++) {
put.add(Bytes.toBytes(cfs[j]),
Bytes.toBytes(String.valueOf(1)), Bytes
.toBytes("value_1"));
table.put(put);
}
} catch (IOException e) {
e.printStackTrace();
}
}


/**
* 刪除一行記錄
* @param tablename
* @param rowkey
* @throws IOException
*/
public void deleteRow(String tablename, String rowkey) throws IOException {
HTable table = new HTable(conf, tablename);
List list = new ArrayList();
Delete d1 = new Delete(rowkey.getBytes());
list.add(d1);
table.delete(list);
System.out.println("刪除行成功!");
}


/**
* 查找一行記錄
* @param tablename
* @param rowkey
*/
public static void selectRow(String tablename, String rowKey)
throws IOException {
HTable table = new HTable(conf, tablename);
Get g = new Get(rowKey.getBytes());
Result rs = table.get(g);
for (KeyValue kv : rs.raw()) {
System.out.print(new String(kv.getRow()) + "  ");
System.out.print(new String(kv.getFamily()) + ":");
System.out.print(new String(kv.getQualifier()) + "  ");
System.out.print(kv.getTimestamp() + "  ");
System.out.println(new String(kv.getValue()));
}
}


/**
* 查詢表中所有行
* @param tablename
*/
public void scaner(String tablename) {
try {
HTable table = new HTable(conf, tablename);
Scan s = new Scan();
ResultScanner rs = table.getScanner(s);
for (Result r : rs) {
KeyValue[] kv = r.raw();
for (int i = 0; i < kv.length; i++) {
System.out.print(new String(kv[i].getRow()) + "  ");
System.out.print(new String(kv[i].getFamily()) + ":");
System.out.print(new String(kv[i].getQualifier()) + "  ");
System.out.print(kv[i].getTimestamp() + "  ");
System.out.println(new String(kv[i].getValue()));
}
}
} catch (IOException e) {
e.printStackTrace();
}
}

public static void main(String[] args) {
Test001 t = new Test001();
String str [] = {"001","002"};
try {
t.createTable("hellohbase", str);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}


}



發佈了36 篇原創文章 · 獲贊 16 · 訪問量 38萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章