Search in sources :

Example 1 with Driver

use of io.vertx.sqlclient.spi.Driver in project hibernate-reactive by hibernate.

the class DefaultSqlClientPool method findDriver.

/**
 * When there are multiple candidate drivers in the classpath,
 * {@link Pool#pool} throws a {@link ServiceConfigurationError},
 * so we need to disambiguate according to the scheme specified
 * in the given {@link URI}.
 *
 * @param uri the JDBC URL or database URI
 * @param originalError the error that was thrown
 *
 * @return the disambiguated {@link Driver}
 */
private Driver findDriver(URI uri, ServiceConfigurationError originalError) {
    String scheme = scheme(uri);
    for (Driver d : ServiceLoader.load(Driver.class)) {
        String driverName = d.getClass().getCanonicalName();
        LOG.detectedDriver(driverName);
        if (matchesScheme(driverName, scheme)) {
            return d;
        }
    }
    throw new ConfigurationException("No suitable drivers found for URI scheme: " + scheme, originalError);
}
Also used : ConfigurationException(org.hibernate.internal.util.config.ConfigurationException) Driver(io.vertx.sqlclient.spi.Driver)

Example 2 with Driver

use of io.vertx.sqlclient.spi.Driver in project vertx-sql-client by eclipse-vertx.

the class DriverTestBase method testServiceLoader.

@Test
public void testServiceLoader(TestContext ctx) {
    List<Driver> drivers = new ArrayList<>();
    for (Driver d : ServiceLoader.load(Driver.class)) {
        drivers.add(d);
    }
    assertEquals("Expected to find exactly 1 Driver but found: " + drivers, 1, drivers.size());
}
Also used : ArrayList(java.util.ArrayList) Driver(io.vertx.sqlclient.spi.Driver) Test(org.junit.Test)

Aggregations

Driver (io.vertx.sqlclient.spi.Driver)2 ArrayList (java.util.ArrayList)1 ConfigurationException (org.hibernate.internal.util.config.ConfigurationException)1 Test (org.junit.Test)1