hbase support

This commit is contained in:
温少
2012-05-18 21:24:13 +08:00
parent 20d770a599
commit b2d558cf19
7 changed files with 611 additions and 953 deletions
@@ -18,8 +18,6 @@ package com.alibaba.druid.mock;
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;
@@ -28,16 +26,7 @@ public class MockStatement extends StatementBase implements Statement {
public final static String ERROR_SQL = "THROW ERROR";
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){
super(connection);
@@ -66,33 +55,6 @@ public class MockStatement extends StatementBase implements Statement {
this.setConnection(fakeConnection);
}
@SuppressWarnings("unchecked")
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
if (iface == null) {
return null;
}
if (iface.isInstance(this)) {
return (T) this;
}
return null;
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
if (iface == null) {
return false;
}
if (iface.isInstance(this)) {
return true;
}
return false;
}
@Override
public ResultSet executeQuery(String sql) throws SQLException {
checkOpen();
@@ -115,95 +77,6 @@ public class MockStatement extends StatementBase implements Statement {
return 0;
}
@Override
public void close() throws SQLException {
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();
@@ -219,122 +92,4 @@ public class MockStatement extends StatementBase implements Statement {
return false;
}
@Override
public ResultSet getResultSet() throws SQLException {
checkOpen();
return new MockResultSet(this);
}
@Override
public int getUpdateCount() throws SQLException {
checkOpen();
return updateCount;
}
public void setUpdateCount(int updateCount) {
this.updateCount = updateCount;
}
@Override
public boolean getMoreResults() throws SQLException {
checkOpen();
return false;
}
@Override
public void addBatch(String sql) throws SQLException {
checkOpen();
}
@Override
public void clearBatch() throws SQLException {
checkOpen();
}
@Override
public int[] executeBatch() throws SQLException {
checkOpen();
if (mockConnection != null) {
mockConnection.handleSleep();
}
return new int[0];
}
@Override
public boolean getMoreResults(int current) throws SQLException {
checkOpen();
return false;
}
@Override
public ResultSet getGeneratedKeys() throws SQLException {
checkOpen();
return new MockResultSet(this);
}
@Override
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
checkOpen();
return 0;
}
@Override
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
checkOpen();
return 0;
}
@Override
public int executeUpdate(String sql, String[] columnNames) throws SQLException {
checkOpen();
return 0;
}
@Override
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
checkOpen();
return false;
}
@Override
public boolean execute(String sql, int[] columnIndexes) throws SQLException {
checkOpen();
return false;
}
@Override
public boolean execute(String sql, String[] columnNames) throws SQLException {
checkOpen();
return false;
}
@Override
public boolean isClosed() throws SQLException {
return closed;
}
@Override
public void setPoolable(boolean poolable) throws SQLException {
checkOpen();
}
@Override
public boolean isPoolable() throws SQLException {
checkOpen();
return false;
}
public void closeOnCompletion() throws SQLException {
throw new SQLFeatureNotSupportedException();
}
public boolean isCloseOnCompletion() throws SQLException {
throw new SQLFeatureNotSupportedException();
}
}