1313import java .util .ServiceConfigurationError ;
1414import java .util .ServiceLoader ;
1515import java .util .concurrent .CompletionStage ;
16+ import java .util .function .Supplier ;
1617
1718import org .hibernate .engine .jdbc .spi .JdbcServices ;
1819import org .hibernate .engine .jdbc .spi .SqlExceptionHelper ;
3132
3233import io .vertx .core .Future ;
3334import io .vertx .core .Vertx ;
35+ import io .vertx .core .net .NetClientOptions ;
3436import io .vertx .sqlclient .Pool ;
3537import io .vertx .sqlclient .PoolOptions ;
3638import io .vertx .sqlclient .SqlConnectOptions ;
39+ import io .vertx .sqlclient .impl .Utils ;
3740import io .vertx .sqlclient .spi .Driver ;
3841
39- import static java .util .Collections .singletonList ;
40-
4142/**
4243 * A pool of reactive connections backed by a Vert.x {@link Pool}.
4344 * The {@code Pool} itself is backed by an instance of {@link Vertx}
@@ -189,7 +190,7 @@ protected Pool createPool(URI uri) {
189190 *
190191 * @return the new {@link Pool}
191192 */
192- protected Pool createPool (URI uri , SqlConnectOptions connectOptions , PoolOptions poolOptions , Vertx vertx ) {
193+ protected < T extends SqlConnectOptions > Pool createPool (URI uri , T connectOptions , PoolOptions poolOptions , Vertx vertx ) {
193194 try {
194195 // First try to load the Pool using the standard ServiceLoader pattern
195196 // This only works if exactly 1 Driver is on the classpath.
@@ -198,8 +199,9 @@ protected Pool createPool(URI uri, SqlConnectOptions connectOptions, PoolOptions
198199 catch (ServiceConfigurationError e ) {
199200 // Backup option if multiple drivers are on the classpath.
200201 // We will be able to remove this once Vertx 3.9.2 is available
201- final Driver driver = findDriver ( uri , e );
202- return driver .createPool ( vertx , singletonList ( connectOptions ), poolOptions );
202+ final Driver <SqlConnectOptions > driver = findDriver ( uri , e );
203+ Supplier <Future <SqlConnectOptions >> database = Utils .singletonSupplier ( driver .downcast ( connectOptions ) );
204+ return driver .createPool ( vertx , database , poolOptions , new NetClientOptions (), null );
203205 }
204206 }
205207
@@ -222,15 +224,14 @@ protected URI jdbcUrl(Map<?,?> configurationValues) {
222224 * so we need to disambiguate according to the scheme specified
223225 * in the given {@link URI}.
224226 *
225- * @param uri the JDBC URL or database URI
227+ * @param uri the JDBC URL or database URI
226228 * @param originalError the error that was thrown
227- *
228229 * @return the disambiguated {@link Driver}
229230 */
230- private Driver findDriver (URI uri , ServiceConfigurationError originalError ) {
231+ private Driver < SqlConnectOptions > findDriver (URI uri , ServiceConfigurationError originalError ) {
231232 String scheme = scheme ( uri );
232- List <Driver > selected = new ArrayList <>();
233- for ( Driver d : ServiceLoader .load ( Driver .class ) ) {
233+ List <Driver < SqlConnectOptions > > selected = new ArrayList <>();
234+ for ( Driver < SqlConnectOptions > d : ServiceLoader .load ( Driver .class ) ) {
234235 String driverName = d .getClass ().getCanonicalName ();
235236 if ( matchesScheme ( driverName , scheme ) ) {
236237 LOG .selectedDriver ( driverName );
0 commit comments