forked from github/dataease
refactor(数据源): 优化数据源连接池
This commit is contained in:
parent
3a9973c68c
commit
57427955db
@ -1345,13 +1345,18 @@ public class CalciteProvider extends Provider {
|
|||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Connection getConnectionFromPool(Long dsId) throws SQLException {
|
private Connection getConnectionFromPool(Long dsId) {
|
||||||
|
try {
|
||||||
Connection connection = take();
|
Connection connection = take();
|
||||||
CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class);
|
CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class);
|
||||||
SchemaPlus rootSchema = calciteConnection.getRootSchema();
|
SchemaPlus rootSchema = calciteConnection.getRootSchema();
|
||||||
JdbcSchema jdbcSchema = rootSchema.getSubSchema(String.format(SQLConstants.SCHEMA, dsId)).unwrap(JdbcSchema.class);
|
JdbcSchema jdbcSchema = rootSchema.getSubSchema(String.format(SQLConstants.SCHEMA, dsId)).unwrap(JdbcSchema.class);
|
||||||
BasicDataSource basicDataSource = (BasicDataSource) jdbcSchema.getDataSource();
|
BasicDataSource basicDataSource = (BasicDataSource) jdbcSchema.getDataSource();
|
||||||
return basicDataSource.getConnection();
|
return basicDataSource.getConnection();
|
||||||
|
} catch (Exception e) {
|
||||||
|
DEException.throwException("连接无效");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void exec(EngineRequest engineRequest) throws Exception {
|
public void exec(EngineRequest engineRequest) throws Exception {
|
||||||
|
Loading…
Reference in New Issue
Block a user