hbase support

This commit is contained in:
温少
2012-05-19 08:19:51 +08:00
5 changed files with 79 additions and 50 deletions
@@ -1,9 +1,14 @@
package com.alibaba.druid.hbase.exec;
import java.util.List;
import java.sql.SQLException;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import com.alibaba.druid.hbase.HBaseConnection;
import com.alibaba.druid.hbase.HBasePreparedStatement;
import com.alibaba.druid.hbase.HBaseResultSet;
public class SingleTableQueryExecutePlan implements ExecutePlan {
@@ -18,8 +23,20 @@ public class SingleTableQueryExecutePlan implements ExecutePlan {
}
@Override
public void execute(HBaseConnection connection, List<Object> paramerers) {
public HBaseResultSet executeScan(HBasePreparedStatement statement) throws SQLException {
try {
HBaseConnection connection = statement.getConnection();
HTableInterface htable = connection.getHTable(tableName);
Scan scan = new Scan();
ResultScanner scanner = htable.getScanner(scan);
return new HBaseResultSet(statement, htable, scanner);
} catch (SQLException e) {
throw e;
} catch (Exception e) {
throw new SQLException("executeQuery error", e);
}
}
}