|
|
|
@ -81,7 +81,7 @@ abstract class PoolBase
|
|
|
|
|
private int defaultTransactionIsolation;
|
|
|
|
|
private int transactionIsolation;
|
|
|
|
|
private Executor netTimeoutExecutor;
|
|
|
|
|
private DataSource dataSource;
|
|
|
|
|
private AtomicReference<DataSource> dataSource;
|
|
|
|
|
|
|
|
|
|
private final String catalog;
|
|
|
|
|
private final String schema;
|
|
|
|
@ -114,6 +114,7 @@ abstract class PoolBase
|
|
|
|
|
this.connectionTimeout = config.getConnectionTimeout();
|
|
|
|
|
this.validationTimeout = config.getValidationTimeout();
|
|
|
|
|
this.lastConnectionFailure = new AtomicReference<>();
|
|
|
|
|
this.dataSource = new AtomicReference<>();
|
|
|
|
|
|
|
|
|
|
initializeDataSource();
|
|
|
|
|
}
|
|
|
|
@ -193,7 +194,7 @@ abstract class PoolBase
|
|
|
|
|
|
|
|
|
|
public DataSource getUnwrappedDataSource()
|
|
|
|
|
{
|
|
|
|
|
return dataSource;
|
|
|
|
|
return dataSource.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***********************************************************************
|
|
|
|
@ -254,7 +255,7 @@ abstract class PoolBase
|
|
|
|
|
long getLoginTimeout()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
return (dataSource != null) ? dataSource.getLoginTimeout() : SECONDS.toSeconds(5);
|
|
|
|
|
return (dataSource != null) ? dataSource.get().getLoginTimeout() : SECONDS.toSeconds(5);
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
return SECONDS.toSeconds(5);
|
|
|
|
|
}
|
|
|
|
@ -324,7 +325,7 @@ abstract class PoolBase
|
|
|
|
|
/**
|
|
|
|
|
* Create/initialize the underlying DataSource.
|
|
|
|
|
*/
|
|
|
|
|
private void initializeDataSource()
|
|
|
|
|
void initializeDataSource()
|
|
|
|
|
{
|
|
|
|
|
final String jdbcUrl = config.getJdbcUrl();
|
|
|
|
|
final String username = config.getUsername();
|
|
|
|
@ -356,7 +357,7 @@ abstract class PoolBase
|
|
|
|
|
createNetworkTimeoutExecutor(dataSource, dsClassName, jdbcUrl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.dataSource = dataSource;
|
|
|
|
|
this.dataSource.set(dataSource);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -373,7 +374,7 @@ abstract class PoolBase
|
|
|
|
|
String username = config.getUsername();
|
|
|
|
|
String password = config.getPassword();
|
|
|
|
|
|
|
|
|
|
connection = (username == null) ? dataSource.getConnection() : dataSource.getConnection(username, password);
|
|
|
|
|
connection = (username == null) ? dataSource.get().getConnection() : dataSource.get().getConnection(username, password);
|
|
|
|
|
if (connection == null) {
|
|
|
|
|
throw new SQLTransientConnectionException("DataSource returned null unexpectedly");
|
|
|
|
|
}
|
|
|
|
|