in wrapper/src/main/java/software/amazon/jdbc/states/SessionStateServiceImpl.java [402:469]
public void applyCurrentSessionState(Connection newConnection) throws SQLException {
if (!this.transferStateEnabledSetting()) {
return;
}
TransferSessionStateOnSwitchCallable callableCopy = Driver.getTransferSessionStateOnSwitchFunc();
if (callableCopy != null) {
final boolean isHandled = callableCopy.apply(sessionState, newConnection);
if (isHandled) {
// Custom function has handled session transfer
return;
}
}
if (this.sessionState.autoCommit.getValue().isPresent()) {
this.sessionState.autoCommit.resetPristineValue();
this.setupPristineAutoCommit();
newConnection.setAutoCommit(this.sessionState.autoCommit.getValue().get());
}
if (this.sessionState.readOnly.getValue().isPresent()) {
this.sessionState.readOnly.resetPristineValue();
this.setupPristineReadOnly();
newConnection.setReadOnly(this.sessionState.readOnly.getValue().get());
}
if (this.sessionState.catalog.getValue().isPresent()) {
this.sessionState.catalog.resetPristineValue();
this.setupPristineCatalog();
final String currentCatalog = this.sessionState.catalog.getValue().get();
if (!StringUtils.isNullOrEmpty(currentCatalog)) {
newConnection.setCatalog(currentCatalog);
}
}
if (this.sessionState.schema.getValue().isPresent()) {
this.sessionState.schema.resetPristineValue();
this.setupPristineSchema();
newConnection.setSchema(this.sessionState.schema.getValue().get());
}
if (this.sessionState.holdability.getValue().isPresent()) {
this.sessionState.holdability.resetPristineValue();
this.setupPristineHoldability();
newConnection.setHoldability(this.sessionState.holdability.getValue().get());
}
if (this.sessionState.transactionIsolation.getValue().isPresent()) {
this.sessionState.transactionIsolation.resetPristineValue();
this.setupPristineTransactionIsolation();
//noinspection MagicConstant
newConnection.setTransactionIsolation(this.sessionState.transactionIsolation.getValue().get());
}
if (this.sessionState.networkTimeout.getValue().isPresent()) {
this.sessionState.networkTimeout.resetPristineValue();
this.setupPristineNetworkTimeout();
final ExecutorService executorService = Executors.newSingleThreadExecutor();
newConnection.setNetworkTimeout(executorService, this.sessionState.networkTimeout.getValue().get());
executorService.shutdown();
}
if (this.sessionState.typeMap.getValue().isPresent()) {
this.sessionState.typeMap.resetPristineValue();
this.setupPristineTypeMap();
newConnection.setTypeMap(this.sessionState.typeMap.getValue().get());
}
}