mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor
This commit is contained in:
@@ -21,7 +21,6 @@ import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.client.HTableInterface;
|
||||
|
||||
import com.alibaba.druid.hdriver.HConnection;
|
||||
import com.alibaba.druid.hdriver.HPreparedStatement;
|
||||
import com.alibaba.druid.hdriver.HStatement;
|
||||
import com.alibaba.druid.hdriver.impl.mapping.HMapping;
|
||||
import com.alibaba.druid.util.jdbc.ConnectionBase;
|
||||
@@ -159,7 +158,12 @@ public class HBaseConnectionImpl extends ConnectionBase implements HConnection {
|
||||
|
||||
@Override
|
||||
public HPreparedStatementImpl prepareStatement(String sql) throws SQLException {
|
||||
return new HPreparedStatementImpl(this, sql);
|
||||
return prepareStatement(sql, (HMapping) null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HPreparedStatementImpl prepareStatement(String sql, HMapping mapping) throws SQLException {
|
||||
return new HPreparedStatementImpl(this, sql, mapping);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -252,9 +256,4 @@ public class HBaseConnectionImpl extends ConnectionBase implements HConnection {
|
||||
return engine.getHTable(tableName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HPreparedStatement prepareStatement(String sql, HMapping mapping) throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.alibaba.druid.hdriver.impl.execute.InsertExecutePlan;
|
||||
import com.alibaba.druid.hdriver.impl.execute.ShowTablesPlan;
|
||||
import com.alibaba.druid.hdriver.impl.execute.SingleTableQueryExecutePlan;
|
||||
import com.alibaba.druid.hdriver.impl.hbql.ast.HBQLShowStatement;
|
||||
import com.alibaba.druid.hdriver.impl.mapping.HMapping;
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
@@ -38,10 +39,13 @@ public class HPreparedStatementImpl extends PreparedStatementBase implements HPr
|
||||
|
||||
private String dbType = "hbase";
|
||||
|
||||
public HPreparedStatementImpl(HBaseConnectionImpl conn, String sql) throws SQLException{
|
||||
private HMapping mapping;
|
||||
|
||||
public HPreparedStatementImpl(HBaseConnectionImpl conn, String sql, HMapping mapping) throws SQLException{
|
||||
super(conn);
|
||||
this.sql = sql;
|
||||
this.hbaseConnection = conn;
|
||||
this.mapping = mapping;
|
||||
|
||||
init();
|
||||
}
|
||||
@@ -58,6 +62,10 @@ public class HPreparedStatementImpl extends PreparedStatementBase implements HPr
|
||||
conditions.add(expr);
|
||||
}
|
||||
|
||||
public HMapping getMapping() {
|
||||
return mapping;
|
||||
}
|
||||
|
||||
public void init() throws SQLException {
|
||||
List<SQLStatement> stmtList = SQLUtils.parseStatements(sql, dbType);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user