diff --git a/wrapper/src/main/java/software/amazon/jdbc/DataSourceConnectionProvider.java b/wrapper/src/main/java/software/amazon/jdbc/DataSourceConnectionProvider.java index 948bdd9a8..d7f1c1566 100644 --- a/wrapper/src/main/java/software/amazon/jdbc/DataSourceConnectionProvider.java +++ b/wrapper/src/main/java/software/amazon/jdbc/DataSourceConnectionProvider.java @@ -131,11 +131,6 @@ public Connection connect( LOGGER.finest(() -> "Use a separate DataSource object to create a connection."); // use a new data source instance to instantiate a connection final DataSource ds = createDataSource(); - targetDriverDialect.prepareDataSource( - ds, - protocol, - hostSpec, - copy); conn = this.openConnection(ds, protocol, targetDriverDialect, hostSpec, copy); } else { @@ -145,11 +140,6 @@ public Connection connect( this.lock.lock(); LOGGER.finest(() -> "Use main DataSource object to create a connection."); try { - targetDriverDialect.prepareDataSource( - this.dataSource, - protocol, - hostSpec, - copy); conn = this.openConnection(this.dataSource, protocol, targetDriverDialect, hostSpec, copy); } finally { this.lock.unlock(); @@ -170,11 +160,16 @@ protected Connection openConnection( final @NonNull HostSpec hostSpec, final @NonNull Properties props) throws SQLException { - + final boolean enableGreenNodeReplacement = PropertyDefinition.ENABLE_GREEN_NODE_REPLACEMENT.getBoolean(props); try { + targetDriverDialect.prepareDataSource( + ds, + protocol, + hostSpec, + props); return ds.getConnection(); } catch (Throwable throwable) { - if (!PropertyDefinition.ENABLE_GREEN_NODE_REPLACEMENT.getBoolean(props)) { + if (!enableGreenNodeReplacement) { throw throwable; }