mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
修正初始化连接创建失败时,数据源继续工作
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@436 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -199,13 +199,17 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
}
|
||||
|
||||
connections = new ConnectionHolder[capacity];
|
||||
// pool = new ConnectionPool(this, this.minIdle, this.maxIdle,
|
||||
// this.maxActive, this.maxIdleTimeMillis);
|
||||
|
||||
for (int i = 0, size = getInitialSize(); i < size; ++i) {
|
||||
Connection conn = connectionFactory.createConnection();
|
||||
conn.setAutoCommit(true);
|
||||
connections[count++] = new ConnectionHolder(this, conn);
|
||||
SQLException connectError = null;
|
||||
|
||||
try {
|
||||
for (int i = 0, size = getInitialSize(); i < size; ++i) {
|
||||
Connection conn = connectionFactory.createConnection();
|
||||
conn.setAutoCommit(true);
|
||||
connections[count++] = new ConnectionHolder(this, conn);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
connectError = ex;
|
||||
}
|
||||
|
||||
createConnectionThread = new CreateConnectionThread("Druid-ConnectionPool-Create");
|
||||
@@ -225,6 +229,10 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
|
||||
createdTime = new Date();
|
||||
instances.put(this, PRESENT);
|
||||
|
||||
if (connectError != null) {
|
||||
throw connectError;
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new SQLException(e.getMessage(), e);
|
||||
} finally {
|
||||
@@ -434,7 +442,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
if (createConnectionThread != null) {
|
||||
createConnectionThread.interrupt();
|
||||
}
|
||||
|
||||
|
||||
if (destoryConnectionThread != null) {
|
||||
destoryConnectionThread.interrupt();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user