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@462 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -54,7 +54,7 @@ public class HAConnection extends WrapperAdapter implements Connection, Connecti
|
||||
|
||||
public void checkConnection(String sql) throws SQLException {
|
||||
if (conn == null) {
|
||||
conn = haDataSource.getConnectionInternal(id);
|
||||
conn = haDataSource.getConnectionInternal(id, sql);
|
||||
}
|
||||
|
||||
if (autoCommit != null) {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class HADataSource extends MultiDataSource implements DataSource {
|
||||
return statementIdSeed.getAndIncrement();
|
||||
}
|
||||
|
||||
public Connection getConnectionInternal(int requestNumber) throws SQLException {
|
||||
public Connection getConnectionInternal(int connectionId, String sql) throws SQLException {
|
||||
int tryCount = 0;
|
||||
|
||||
for (;;) {
|
||||
@@ -46,7 +46,7 @@ public class HADataSource extends MultiDataSource implements DataSource {
|
||||
throw new SQLException("can not get connection, no availabe datasources");
|
||||
}
|
||||
|
||||
int index = requestNumber % size;
|
||||
int index = connectionId % size;
|
||||
|
||||
DruidDataSource dataSource = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user