hbase support

This commit is contained in:
温少
2012-05-18 20:34:27 +08:00
parent 20d770a599
commit c9204dc18a
3 changed files with 92 additions and 192 deletions
@@ -2,6 +2,7 @@ package com.alibaba.druid.common.jdbc;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;
public abstract class StatementBase implements Statement {
@@ -12,6 +13,12 @@ public abstract class StatementBase implements Statement {
private int resultSetType;
private int resultSetConcurrency;
private int resultSetHoldability;
private int maxFieldSize;
private int maxRows;
private int queryTimeout;
private boolean escapeProcessing;
private String cursorName;
private SQLWarning warnings;
public StatementBase(Connection connection){
super();
@@ -84,4 +91,83 @@ public abstract class StatementBase implements Statement {
public void setResultSetHoldability(int resultSetHoldability) {
this.resultSetHoldability = resultSetHoldability;
}
@Override
public int getMaxFieldSize() throws SQLException {
checkOpen();
return maxFieldSize;
}
@Override
public void setMaxFieldSize(int max) throws SQLException {
checkOpen();
this.maxFieldSize = max;
}
@Override
public int getMaxRows() throws SQLException {
checkOpen();
return maxRows;
}
@Override
public void setMaxRows(int max) throws SQLException {
checkOpen();
this.maxRows = max;
}
@Override
public void setEscapeProcessing(boolean enable) throws SQLException {
checkOpen();
this.escapeProcessing = enable;
}
public boolean isEscapeProcessing() {
return escapeProcessing;
}
@Override
public int getQueryTimeout() throws SQLException {
checkOpen();
return queryTimeout;
}
@Override
public void setQueryTimeout(int seconds) throws SQLException {
checkOpen();
this.queryTimeout = seconds;
}
@Override
public void setCursorName(String name) throws SQLException {
checkOpen();
cursorName = name;
}
public String getCursorName() {
return cursorName;
}
@Override
public SQLWarning getWarnings() throws SQLException {
checkOpen();
return warnings;
}
@Override
public void clearWarnings() throws SQLException {
checkOpen();
warnings = null;
}
public void setWarning(SQLWarning warning) {
this.warnings = warning;
}
}
@@ -3,15 +3,16 @@ package com.alibaba.druid.hbase;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;
public class HBaseStatement implements Statement {
import com.alibaba.druid.common.jdbc.StatementBase;
public class HBaseStatement extends StatementBase implements Statement {
private HBaseConnection conn;
public HBaseStatement(HBaseConnection conn){
super();
super(conn);
this.conn = conn;
}
@@ -45,69 +46,8 @@ public class HBaseStatement implements Statement {
}
@Override
public int getMaxFieldSize() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public void setMaxFieldSize(int max) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public int getMaxRows() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public void setMaxRows(int max) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setEscapeProcessing(boolean enable) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public int getQueryTimeout() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public void setQueryTimeout(int seconds) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void cancel() throws SQLException {
// TODO Auto-generated method stub
}
@Override
public SQLWarning getWarnings() throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public void clearWarnings() throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void setCursorName(String name) throws SQLException {
// TODO Auto-generated method stub
}
@@ -135,42 +75,6 @@ public class HBaseStatement implements Statement {
return false;
}
@Override
public void setFetchDirection(int direction) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public int getFetchDirection() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public void setFetchSize(int rows) throws SQLException {
// TODO Auto-generated method stub
}
@Override
public int getFetchSize() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getResultSetConcurrency() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getResultSetType() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public void addBatch(String sql) throws SQLException {
// TODO Auto-generated method stub
@@ -242,11 +146,6 @@ public class HBaseStatement implements Statement {
return false;
}
@Override
public int getResultSetHoldability() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean isClosed() throws SQLException {
@@ -267,6 +166,6 @@ public class HBaseStatement implements Statement {
}
public void checkOpen() {
}
}
@@ -19,7 +19,6 @@ import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.sql.SQLWarning;
import java.sql.Statement;
import com.alibaba.druid.common.jdbc.StatementBase;
@@ -31,12 +30,7 @@ public class MockStatement extends StatementBase implements Statement {
protected boolean closed = false;
protected MockConnection mockConnection;
private int maxFieldSize;
private int maxRows;
private int queryTimeout;
private boolean escapeProcessing;
private SQLWarning warnings;
private String cursorName;
private int updateCount;
public MockStatement(Connection connection){
@@ -120,90 +114,11 @@ public class MockStatement extends StatementBase implements Statement {
this.closed = true;
}
@Override
public int getMaxFieldSize() throws SQLException {
checkOpen();
return maxFieldSize;
}
@Override
public void setMaxFieldSize(int max) throws SQLException {
checkOpen();
this.maxFieldSize = max;
}
@Override
public int getMaxRows() throws SQLException {
checkOpen();
return maxRows;
}
@Override
public void setMaxRows(int max) throws SQLException {
checkOpen();
this.maxRows = max;
}
@Override
public void setEscapeProcessing(boolean enable) throws SQLException {
checkOpen();
this.escapeProcessing = enable;
}
public boolean isEscapeProcessing() {
return escapeProcessing;
}
@Override
public int getQueryTimeout() throws SQLException {
checkOpen();
return queryTimeout;
}
@Override
public void setQueryTimeout(int seconds) throws SQLException {
checkOpen();
this.queryTimeout = seconds;
}
@Override
public void cancel() throws SQLException {
checkOpen();
}
@Override
public SQLWarning getWarnings() throws SQLException {
checkOpen();
return warnings;
}
@Override
public void clearWarnings() throws SQLException {
checkOpen();
warnings = null;
}
public void setWarning(SQLWarning warning) {
this.warnings = warning;
}
@Override
public void setCursorName(String name) throws SQLException {
checkOpen();
cursorName = name;
}
public String getCursorName() {
return cursorName;
}
@Override
public boolean execute(String sql) throws SQLException {
checkOpen();