mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
支持HA
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@464 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -25,7 +25,7 @@ public class HADataSource extends MultiDataSource implements DataSource {
|
||||
|
||||
@Override
|
||||
public Connection getConnection() throws SQLException {
|
||||
return new HAConnection(this, createConnectionId());
|
||||
return new MultiDataSourceConnection(this, createConnectionId());
|
||||
}
|
||||
|
||||
public Connection getConnectionInternal(int connectionId, String sql) throws SQLException {
|
||||
|
||||
+5
-5
@@ -26,7 +26,7 @@ import com.alibaba.druid.proxy.jdbc.ConnectionProxy;
|
||||
import com.alibaba.druid.proxy.jdbc.DataSourceProxy;
|
||||
import com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl;
|
||||
|
||||
public class HAConnection extends WrapperAdapter implements Connection, ConnectionProxy {
|
||||
public class MultiDataSourceConnection extends WrapperAdapter implements Connection, ConnectionProxy {
|
||||
|
||||
private final MultiDataSource haDataSource;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class HAConnection extends WrapperAdapter implements Connection, Connecti
|
||||
|
||||
private Date connectedTime = null;
|
||||
|
||||
public HAConnection(HADataSource haDataSource, int id){
|
||||
public MultiDataSourceConnection(HADataSource haDataSource, int id){
|
||||
this.haDataSource = haDataSource;
|
||||
this.id = id;
|
||||
}
|
||||
@@ -317,14 +317,14 @@ public class HAConnection extends WrapperAdapter implements Connection, Connecti
|
||||
@Override
|
||||
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
|
||||
long stmtId = haDataSource.createStatementId();
|
||||
HAStatement stmt = new HAStatement(this, stmtId, resultSetType, resultSetConcurrency);
|
||||
MultiDataSourceStatement stmt = new MultiDataSourceStatement(this, stmtId, resultSetType, resultSetConcurrency);
|
||||
return stmt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Statement createStatement() throws SQLException {
|
||||
long stmtId = haDataSource.createStatementId();
|
||||
HAStatement stmt = new HAStatement(this, stmtId);
|
||||
MultiDataSourceStatement stmt = new MultiDataSourceStatement(this, stmtId);
|
||||
return stmt;
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ public class HAConnection extends WrapperAdapter implements Connection, Connecti
|
||||
@Override
|
||||
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
|
||||
long stmtId = haDataSource.createStatementId();
|
||||
HAStatement stmt = new HAStatement(this, stmtId, resultSetType, resultSetConcurrency, resultSetHoldability);
|
||||
MultiDataSourceStatement stmt = new MultiDataSourceStatement(this, stmtId, resultSetType, resultSetConcurrency, resultSetHoldability);
|
||||
return stmt;
|
||||
}
|
||||
|
||||
+6
-6
@@ -7,9 +7,9 @@ import java.sql.Statement;
|
||||
|
||||
import com.alibaba.druid.pool.WrapperAdapter;
|
||||
|
||||
public class HAStatement extends WrapperAdapter implements Statement {
|
||||
public class MultiDataSourceStatement extends WrapperAdapter implements Statement {
|
||||
|
||||
private final HAConnection conn;
|
||||
private final MultiDataSourceConnection conn;
|
||||
private final long id;
|
||||
private Integer resultSetType;
|
||||
private Integer resultSetConcurrency;
|
||||
@@ -59,13 +59,13 @@ public class HAStatement extends WrapperAdapter implements Statement {
|
||||
}
|
||||
|
||||
|
||||
public HAStatement(HAConnection conn, long id){
|
||||
public MultiDataSourceStatement(MultiDataSourceConnection conn, long id){
|
||||
super();
|
||||
this.conn = conn;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public HAStatement(HAConnection conn, long id, int resultSetType, int resultSetConcurrency){
|
||||
public MultiDataSourceStatement(MultiDataSourceConnection conn, long id, int resultSetType, int resultSetConcurrency){
|
||||
super();
|
||||
this.conn = conn;
|
||||
this.id = id;
|
||||
@@ -73,7 +73,7 @@ public class HAStatement extends WrapperAdapter implements Statement {
|
||||
this.resultSetConcurrency = resultSetConcurrency;
|
||||
}
|
||||
|
||||
public HAStatement(HAConnection conn, long id, int resultSetType, int resultSetConcurrency, int resultSetHoldability){
|
||||
public MultiDataSourceStatement(MultiDataSourceConnection conn, long id, int resultSetType, int resultSetConcurrency, int resultSetHoldability){
|
||||
super();
|
||||
this.conn = conn;
|
||||
this.id = id;
|
||||
@@ -335,7 +335,7 @@ public class HAStatement extends WrapperAdapter implements Statement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HAConnection getConnection() throws SQLException {
|
||||
public MultiDataSourceConnection getConnection() throws SQLException {
|
||||
return conn;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user