/** * Creates the data source based on a `Config` instance. * * @param config * the config * @return the data source instance */ public static DataSource<PreparedStatement, Row> fromConfig(final Config config) { return create(io.trane.ndbc.DataSource.fromConfig(config)); }
/** * Creates the data source based on a `Config` instance. * * @param config * the config * @return the data source instance */ public static PostgresDataSource fromConfig(final Config config) { return create(DataSource.fromConfig(config)); }
/** * Creates the data source based on a `Config` instance. * * @param config * the config * @return the data source instance */ public static MysqlDataSource fromConfig(final Config config) { return create(DataSource.fromConfig(config)); }
/** * Creates the data source based on a `Config` instance. * * @param config * the config * @return the data source instance */ public static DataSource<PreparedStatement, Row> fromConfig(final Config config) { return create(io.trane.ndbc.DataSource.fromConfig(config)); }
/** * Creates the data source based on system properties. See * `Config.fromSystemProperties` for more details. * * @param prefix * the configuration prefix * @return the data source instance */ public static DataSource<PreparedStatement, Row> fromSystemProperties(final String prefix) { return fromConfig(Config.fromSystemProperties(prefix)); }
/** * Creates the data source based on a `Config` instance. * * @param config * the config * @return the data source instance */ public static DataSource<PreparedStatement, Row> fromConfig(final Config config) { return create(io.trane.ndbc.DataSource.fromConfig(config)); }
/** * Creates the data source based on a `Config` instance. * * @param config * the config * @return the data source instance */ public static DataSource<PreparedStatement, Row> fromConfig(final Config config) { return create(io.trane.ndbc.DataSource.fromConfig(config)); }
/** * Creates the data source based on a JDBC url. See `Config.fromJdbcUrl` for * more details. * * @param url * the JDBC url * @return the data source instance */ public static DataSource<PreparedStatement, Row> fromJdbcUrl(final String url) { return fromConfig(Config.fromJdbcUrl(url)); }
/** * Creates the data source based on a `Config` instance. * * @param config * the config * @return the data source instance */ public static DataSource<PreparedStatement, Row> fromConfig(final Config config) { return create(io.trane.ndbc.DataSource.fromConfig(config)); }
/** * Creates the data source based on a `Config` instance. * * @param config * the config * @return the data source instance */ public static DataSource<PreparedStatement, Row> fromConfig(final Config config) { return create(io.trane.ndbc.DataSource.fromConfig(config)); }
/** * Creates the data source based on a `Properties` object. See * `Config.fromProperties` for more details. * * @param prefix * the configuration prefix * @param properties * the properties object * @return the data source instance */ public static DataSource<PreparedStatement, Row> fromProperties(final String prefix, final Properties properties) { return fromConfig(Config.fromProperties(prefix, properties)); }
/** * Creates the data source based on a properties file. See * `Config.fromPropertiesFile` for more details. * * @param prefix * the configuration prefix * @param fileName * the properties file path * @return the data source instance * @throws IOException * if the file can't read */ public static DataSource<PreparedStatement, Row> fromPropertiesFile(final String prefix, final String fileName) throws IOException { return fromConfig(Config.fromPropertiesFile(prefix, fileName)); }
final DataSource<PreparedStatement, Row> underlying = DataSource.fromConfig(config.embedded(Optional.empty())); return new ProxyDataSource<PreparedStatement, Row>(underlying) { @Override
@Override public DataSource<PreparedStatement, Row> get() { log.info("Starting embedded mysql " + version + " on port " + config.port()); final String password = config.password().orElseGet(() -> { throw new UnsupportedOperationException("Embedded mysql requires a password"); }); final DownloadConfig downloadConfig = DownloadConfig.aDownloadConfig() .withCacheDir(Paths.get(System.getProperty("user.home"), ".ndbc", "embedded_mysql").toString()) .build(); final MysqldConfig mysqldConfig = MysqldConfig.aMysqldConfig(version) .withPort(config.port()) .withUser(config.user(), password) .build(); final Builder builder = EmbeddedMysql.anEmbeddedMysql(mysqldConfig, downloadConfig); config.database().ifPresent(db -> builder.addSchema(SchemaConfig.aSchemaConfig(db).build())); final EmbeddedMysql mysql = builder.start(); Runtime.getRuntime().addShutdownHook(new Thread(() -> mysql.stop())); log.info("mysql " + version + " started"); DataSource<PreparedStatement, Row> underlying = DataSource.fromConfig(config.embedded(Optional.empty())); return new ProxyDataSource<PreparedStatement, Row>(underlying) { @Override public Config config() { return EmbeddedSupplier.this.config; } }; }