org.flywaydb.core.Flyway.getDataSource()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中org.flywaydb.core.Flyway.getDataSource()方法的一些代码示例,展示了Flyway.getDataSource()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flyway.getDataSource()方法的具体详情如下:
包路径:org.flywaydb.core.Flyway
类名称:Flyway
方法名:getDataSource

Flyway.getDataSource介绍

暂无

代码示例

代码示例来源:origin: hortonworks/registry

private void checkConnection() {
  try (Connection connection = flyway.getDataSource().getConnection()) {
    // do nothing
  } catch (Exception e) {
    throw new SchemaMigrationException(e);
  }
}

代码示例来源:origin: ch.inftec.flyway/flyway-extension-core

public RepeatableMigrationResolver(Flyway flyway, String prefix, Location location) throws SQLException {
  this.prefix = prefix;
  this.location = location;
  this.flyway = flyway;
  this.dbSupport = DbSupportFactory.createDbSupport(flyway.getDataSource().getConnection(), false);
}

代码示例来源:origin: com.hortonworks.registries/storage-tool

private void checkConnection() {
  try (Connection connection = flyway.getDataSource().getConnection()) {
    // do nothing
  } catch (Exception e) {
    throw new SchemaMigrationException(e);
  }
}

代码示例来源:origin: com.hortonworks.registries/storage-tool

private void create() throws SQLException {
  try (Connection connection = flyway.getDataSource().getConnection()) {
    if (!isDatabaseEmpty(connection))
      throw new SchemaMigrationException("Please use an empty database or use \"migrate\" if you are already running a previous version.");
  }
  flyway.migrate();
}

代码示例来源:origin: hortonworks/registry

private void create() throws SQLException {
  try (Connection connection = flyway.getDataSource().getConnection()) {
    if (!isDatabaseEmpty(connection))
      throw new SchemaMigrationException("Please use an empty database or use \"migrate\" if you are already running a previous version.");
  }
  flyway.migrate();
}

代码示例来源:origin: org.apache.nifi.registry/nifi-registry-framework

@Override
public void migrate(Flyway flyway) {
  final boolean newDatabase = isNewDatabase(flyway.getDataSource());
  if (newDatabase) {
    LOGGER.info("First time initializing database...");
  } else {
    LOGGER.info("Found existing database...");
  }
  boolean existingLegacyDatabase = false;
  if (!StringUtils.isBlank(properties.getLegacyDatabaseDirectory())) {
    LOGGER.info("Found legacy database properties...");
    final File legacyDatabaseFile = new File(properties.getLegacyDatabaseDirectory(), "nifi-registry.mv.db");
    if (legacyDatabaseFile.exists()) {
      LOGGER.info("Found legacy database file...");
      existingLegacyDatabase = true;
    } else {
      LOGGER.info("Did not find legacy database file...");
      existingLegacyDatabase = false;
    }
  }
  // If newDatabase is true, then we need to run the Flyway migration first to create all the tables, then the data migration
  // If newDatabase is false, then we need to run the Flyway migration to run any schema updates, but no data migration
  flyway.migrate();
  if (newDatabase && existingLegacyDatabase) {
    final LegacyDataSourceFactory legacyDataSourceFactory = new LegacyDataSourceFactory(properties);
    final DataSource legacyDataSource = legacyDataSourceFactory.getDataSource();
    final DataSource primaryDataSource = flyway.getDataSource();
    migrateData(legacyDataSource, primaryDataSource);
  }
}

代码示例来源:origin: icode/ameba

Flyway flyway = locator.getService(Flyway.class, dbName);
boolean hasTable;
try (Connection connection = flyway.getDataSource().getConnection()) {
  hasTable = connection.getMetaData().getTables(null, null, flyway.getTable(), null).next();
} catch (SQLException e) {

代码示例来源:origin: org.mycontroller.standalone/mycontroller-core

if (!flyway.getDataSource().getConnection().isClosed()) {
  flyway.getDataSource().getConnection().close();
  _logger.debug("Closed flyway database connection.");

代码示例来源:origin: mycontroller-org/mycontroller

if (!flyway.getDataSource().getConnection().isClosed()) {
  flyway.getDataSource().getConnection().close();
  _logger.debug("Closed flyway database connection.");

相关文章