add testcase & bug fixed

This commit is contained in:
wenshao
2012-08-24 22:12:34 +08:00
parent ba6a699c20
commit 41efb5dcbe
6 changed files with 329 additions and 9 deletions
@@ -218,8 +218,9 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
return;
}
this.poolPreparedStatements = value;
if (!inited) {
this.poolPreparedStatements = value;
return;
}
@@ -227,22 +228,22 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
LOG.info("set poolPreparedStatements " + this.poolPreparedStatements + " -> " + value);
}
lock.lock();
try {
if (this.poolPreparedStatements && (!value)) {
if (!value) {
lock.lock();
try {
for (int i = 0; i < poolingCount; ++i) {
DruidConnectionHolder connection = connections[i];
for (PreparedStatementHolder holder : connection.getStatementPool().getMap().values()) {
closePreapredStatement(holder);
decrementCachedPreparedStatementCount();
}
connection.getStatementPool().getMap().clear();
}
} finally {
lock.unlock();
}
} finally {
lock.unlock();
}
}
@@ -1804,6 +1805,10 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
return this.getDataSourceStat().getSqlStat(sqlId);
}
public JdbcSqlStat getSqlStat(long sqlId) {
return this.getDataSourceStat().getSqlStat(sqlId);
}
public Map<String, JdbcSqlStat> getSqlStatMap() {
return this.getDataSourceStat().getSqlStatMap();
}