mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
package com.alibaba.druid.hdriver;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.alibaba.druid.hdriver.impl.jdbc.HPreparedStatementImpl;
|
||||
|
||||
public interface HConnection extends Connection {
|
||||
|
||||
HPreparedStatementImpl prepareStatement(String sql) throws SQLException;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public class HDriver implements Driver {
|
||||
public static String PREFIX = "jdbc:druid-hbase:";
|
||||
|
||||
@Override
|
||||
public HBaseConnectionImpl connect(String url, Properties info) throws SQLException {
|
||||
public HConnection connect(String url, Properties info) throws SQLException {
|
||||
if (!acceptsURL(url)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.alibaba.druid.hdriver;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
|
||||
|
||||
public interface HPreparedStatement extends PreparedStatement, HStatement {
|
||||
|
||||
public HResultSet executeQuery() throws SQLException;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.alibaba.druid.hdriver;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
|
||||
public interface HResultSet extends ResultSet {
|
||||
|
||||
HStatement getStatement() throws SQLException;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.alibaba.druid.hdriver;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
import com.alibaba.druid.hdriver.impl.jdbc.HBaseConnectionImpl;
|
||||
|
||||
public interface HStatement extends Statement {
|
||||
HBaseConnectionImpl getConnection() throws SQLException;
|
||||
HConnection getConnection() throws SQLException;
|
||||
|
||||
HResultSet getResultSet() throws SQLException;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.client.HBaseAdmin;
|
||||
|
||||
import com.alibaba.druid.hdriver.HResultSet;
|
||||
import com.alibaba.druid.hdriver.HStatement;
|
||||
import com.alibaba.druid.hdriver.impl.jdbc.HPreparedStatementImpl;
|
||||
import com.alibaba.druid.hdriver.impl.jdbc.HResultSetMetaData;
|
||||
import com.alibaba.druid.util.jdbc.ResultSetBase;
|
||||
@@ -169,5 +170,10 @@ public class ShowTablesPlan implements ExecutePlan {
|
||||
@Override
|
||||
public void updateObject(int columnIndex, Object x) throws SQLException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HStatement getStatement() throws SQLException {
|
||||
return (HStatement) statement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.alibaba.druid.hdriver.impl.jdbc;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.hdriver.HPreparedStatement;
|
||||
import com.alibaba.druid.hdriver.HResultSet;
|
||||
import com.alibaba.druid.hdriver.impl.execute.ExecutePlan;
|
||||
import com.alibaba.druid.hdriver.impl.execute.InsertExecutePlan;
|
||||
import com.alibaba.druid.hdriver.impl.execute.ShowTablesPlan;
|
||||
@@ -29,14 +29,14 @@ import com.alibaba.druid.util.jdbc.ResultSetMetaDataBase.ColumnMetaData;
|
||||
|
||||
public class HPreparedStatementImpl extends PreparedStatementBase implements HPreparedStatement {
|
||||
|
||||
private final String sql;
|
||||
private String[] columnNames;
|
||||
private final String sql;
|
||||
private String[] columnNames;
|
||||
|
||||
private HBaseConnectionImpl hbaseConnection;
|
||||
|
||||
private ExecutePlan executePlan;
|
||||
private ExecutePlan executePlan;
|
||||
|
||||
private String dbType = "hbase";
|
||||
private String dbType = "hbase";
|
||||
|
||||
public HPreparedStatementImpl(HBaseConnectionImpl conn, String sql) throws SQLException{
|
||||
super(conn);
|
||||
@@ -145,7 +145,7 @@ public class HPreparedStatementImpl extends PreparedStatementBase implements HPr
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet executeQuery() throws SQLException {
|
||||
public HResultSet executeQuery() throws SQLException {
|
||||
return this.executePlan.executeQuery(this);
|
||||
}
|
||||
|
||||
@@ -162,4 +162,7 @@ public class HPreparedStatementImpl extends PreparedStatementBase implements HPr
|
||||
return false;
|
||||
}
|
||||
|
||||
public HResultSet getResultSet() throws SQLException {
|
||||
return (HResultSet) super.getResultSet();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.alibaba.druid.hdriver.impl.jdbc;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.sql.Types;
|
||||
|
||||
import org.apache.hadoop.hbase.client.HTableInterface;
|
||||
@@ -44,7 +43,7 @@ public class HScannerResultSet extends ResultSetBase implements HResultSet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Statement getStatement() throws SQLException {
|
||||
public HStatement getStatement() throws SQLException {
|
||||
return statement;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.alibaba.druid.hdriver.impl.jdbc;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
import com.alibaba.druid.hdriver.HResultSet;
|
||||
import com.alibaba.druid.hdriver.HStatement;
|
||||
import com.alibaba.druid.util.jdbc.StatementBase;
|
||||
|
||||
@@ -23,4 +24,8 @@ public class HStatementImpl extends StatementBase implements Statement, HStateme
|
||||
public void checkOpen() {
|
||||
|
||||
}
|
||||
|
||||
public HResultSet getResultSet() throws SQLException {
|
||||
return (HResultSet) super.getResultSet();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,14 +25,14 @@ import java.util.Map;
|
||||
|
||||
public abstract class ResultSetBase implements ResultSet {
|
||||
|
||||
protected boolean closed = false;
|
||||
protected boolean wasNull = false;
|
||||
private SQLWarning warning;
|
||||
private String cursorName;
|
||||
private int fetchSize = 0;
|
||||
private int fetchDirection = 0;
|
||||
protected boolean closed = false;
|
||||
protected boolean wasNull = false;
|
||||
private SQLWarning warning;
|
||||
private String cursorName;
|
||||
private int fetchSize = 0;
|
||||
private int fetchDirection = 0;
|
||||
|
||||
private Statement statement;
|
||||
protected Statement statement;
|
||||
protected ResultSetMetaData metaData;
|
||||
|
||||
public ResultSetBase(Statement statement){
|
||||
@@ -309,7 +309,7 @@ public abstract class ResultSetBase implements ResultSet {
|
||||
String columName = this.getMetaData().getColumnName(columnIndex);
|
||||
return getObject(columName);
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1166,7 +1166,7 @@ public abstract class ResultSetBase implements ResultSet {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResultSetMetaData getMetaData() throws SQLException {
|
||||
if (closed) {
|
||||
|
||||
Reference in New Issue
Block a user