This commit is contained in:
温少
2012-05-18 21:41:02 +08:00
parent ae2b938239
commit 98129de278
3 changed files with 26 additions and 29 deletions
@@ -5,6 +5,7 @@ import java.sql.SQLException;
import java.sql.SQLWarning;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
public abstract class ConnectionBase implements Connection {
@@ -16,6 +17,22 @@ public abstract class ConnectionBase implements Connection {
private SQLWarning warings;
private boolean readOnly;
private String url;
private Properties info;
public ConnectionBase(String url, Properties info){
this.url = url;
this.info = info;
}
public String getUrl() {
return url;
}
public Properties getConnectProperties() {
return info;
}
@Override
public void setAutoCommit(boolean autoCommit) throws SQLException {
this.autoCommit = autoCommit;
@@ -25,10 +25,9 @@ import com.alibaba.druid.common.jdbc.ConnectionBase;
public class HBaseConnection extends ConnectionBase implements Connection {
private Configuration config;
private final String url;
public HBaseConnection(String url, Properties info){
this.url = url;
super(url, info);
config = new Configuration();
this.setClientInfo(info);
}
@@ -104,10 +103,6 @@ public class HBaseConnection extends ConnectionBase implements Connection {
return null;
}
public String getUrl() {
return url;
}
@Override
public boolean isClosed() throws SQLException {
return false;
@@ -153,35 +148,35 @@ public class HBaseConnection extends ConnectionBase implements Connection {
}
@Override
public PreparedStatement prepareStatement(String sql) throws SQLException {
public HBasePreparedStatement prepareStatement(String sql) throws SQLException {
return new HBasePreparedStatement(this, sql);
}
@Override
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
return new HBasePreparedStatement(this, sql);
return prepareStatement(sql);
}
@Override
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
throws SQLException {
return new HBasePreparedStatement(this, sql);
return prepareStatement(sql);
}
@Override
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
int resultSetHoldability) throws SQLException {
return new HBasePreparedStatement(this, sql);
return prepareStatement(sql);
}
@Override
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
return new HBasePreparedStatement(this, sql);
return prepareStatement(sql);
}
@Override
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
HBasePreparedStatement stmt = new HBasePreparedStatement(this, sql);
HBasePreparedStatement stmt = prepareStatement(sql);
stmt.setColumnNames(columnNames);
return stmt;
}
@@ -44,36 +44,25 @@ public class MockConnection extends ConnectionBase implements Connection {
private MockDriver driver;
private Properties connectProperties;
private long id;
private final long createdTimeMillis = System.currentTimeMillis();
private long lastActiveTimeMillis = System.currentTimeMillis();
private String url;
public MockConnection(){
this(null, null, null);
}
public MockConnection(MockDriver driver, String url, Properties connectProperties){
super(url, connectProperties);
this.driver = driver;
this.connectProperties = connectProperties;
this.url = url;
if (driver != null) {
this.id = driver.generateConnectionId();
}
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public long getLastActiveTimeMillis() {
return lastActiveTimeMillis;
}
@@ -94,10 +83,6 @@ public class MockConnection extends ConnectionBase implements Connection {
return driver;
}
public Properties getConnectProperties() {
return connectProperties;
}
public void setDriver(MockDriver driver) {
this.driver = driver;
}