class DataSourceFactory {

    public static PoolableDataSource create(String url, Properties mysqlConnectionProperties) {
        
        String driver = null;
        try {
            if (url.indexOf(":mysql:") > 0) {
                
                driver = System.getProperty(DRIVER_CLASS_NAME, "com.mysql.cj.jdbc.Driver");
                Class.forName(driver);
                
                ConnectionFactory connectionFactory =
                    new DriverManagerConnectionFactory(url, mysqlConnectionProperties);
                return create(connectionFactory);
                
            } else {
                throw new RuntimeException("Cannot figure out how to instantiate this data source: " + url);
            }
        } catch (ClassNotFoundException e) {
            throw new RuntimeException("Cannot load driver class: " + driver);
        } catch (Exception exc) {
            throw new RuntimeException("Failed to create database source(" +
                url + ") with driver(" + driver + ")", exc);
        }
    }

}