mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
hbase support
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user