liquibase.Liquibase.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(182)

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

Liquibase.<init>介绍

暂无

代码示例

代码示例来源:origin: traccar/traccar

private void initDatabaseSchema() throws SQLException, LiquibaseException {
  if (config.hasKey("database.changelog")) {
    ResourceAccessor resourceAccessor = new FileSystemResourceAccessor();
    Database database = DatabaseFactory.getInstance().openDatabase(
        config.getString("database.url"),
        config.getString("database.user"),
        config.getString("database.password"),
        config.getString("database.driver"),
        null, null, null, resourceAccessor);
    Liquibase liquibase = new Liquibase(
        config.getString("database.changelog"), resourceAccessor, database);
    liquibase.clearCheckSums();
    liquibase.update(new Contexts());
  }
}

代码示例来源:origin: openmrs/openmrs-core

public void upgrade(String filename) throws IOException, SQLException {
  try {
    Liquibase liquibase = new Liquibase(filename, new ClassLoaderResourceAccessor(getClass()
        .getClassLoader()), liqubaseConnection);
    liquibase.update(null);
    
    connection.commit();
  }
  catch (LiquibaseException e) {
    throw new IOException(e);
  }
}

代码示例来源:origin: openmrs/openmrs-core

return new Liquibase(changeLogFile, new CompositeResourceAccessor(openmrsFO, fsFO), database);

代码示例来源:origin: org.liquibase/liquibase-maven-plugin

@Override
protected Liquibase createLiquibase(ResourceAccessor fo, Database db) throws MojoExecutionException {
     String changeLog = (changeLogFile == null) ? "" : changeLogFile.trim();
     return new Liquibase(changeLog, fo, db);
}

代码示例来源:origin: HubSpot/Singularity

@Before
public void createTestData() throws Exception {
 Handle handle = dbiProvider.get().open();
 Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(handle.getConnection()));
 Liquibase liquibase = new Liquibase("singularity_test.sql", new FileSystemResourceAccessor(), database);
 liquibase.update((String) null);
 try {
  database.close();
 } catch (Throwable t) {
 }
 handle.close();
}

代码示例来源:origin: org.flowable/flowable-cmmn-engine

public Liquibase createLiquibaseInstance(Database database) throws LiquibaseException {
  return new Liquibase(LIQUIBASE_CHANGELOG, new ClassLoaderResourceAccessor(), database);
}

代码示例来源:origin: org.flowable/flowable-app-engine

public Liquibase createLiquibaseInstance(Database database) throws LiquibaseException {
  return new Liquibase(LIQUIBASE_CHANGELOG, new ClassLoaderResourceAccessor(), database);
}

代码示例来源:origin: zapodot/embedded-db-junit

private Liquibase createLiquibase(final Connection connection) {
  try {
    JdbcConnection conn = new JdbcConnection(connection);
    Database database = resolveDatabase(connection);
    database.setConnection(conn);
    if (defaultSchemaName != null) {
      database.setDefaultSchemaName(defaultSchemaName);
    }
    return new Liquibase(changeLog, resourceAccessor, database);
  } catch (LiquibaseException e) {
    throw new IllegalStateException("Could not initialize Liquibase", e);
  }
}

代码示例来源:origin: org.liquibase/liquibase-cdi

protected Liquibase createLiquibase(Connection c) throws LiquibaseException {
  Liquibase liquibase = new Liquibase(config.getChangeLog(), resourceAccessor, createDatabase(c));
  if (config.getParameters() != null) {
    for(Map.Entry<String, String> entry: config.getParameters().entrySet()) {
      liquibase.setChangeLogParameter(entry.getKey(), entry.getValue());
    }
  }
  if (config.isDropFirst()) {
    liquibase.dropAll();
  }
  return liquibase;
}

代码示例来源:origin: org.aktin/broker-server

/**
 * Construct a liquibase wrapper for sql connection.
 * Closing the wrapper will not call {@link Connection#close()}.
 * @param connection database connection
 * @throws LiquibaseException error
 */
public LiquibaseWrapper(Connection connection) throws LiquibaseException{
  database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
  ResourceAccessor ra = new ClassResourceAccessor(LiquibaseWrapper.class);
  liquibase = new Liquibase(CHANGELOG_RESOURCE, ra, database);
}

代码示例来源:origin: org.keycloak/keycloak-model-jpa

@Override
public Liquibase getLiquibase(Connection connection, String defaultSchema) throws LiquibaseException {
  Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
  if (defaultSchema != null) {
    database.setDefaultSchemaName(defaultSchema);
  }
  String changelog = LiquibaseJpaUpdaterProvider.CHANGELOG;
  ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor(getClass().getClassLoader());
  logger.debugf("Using changelog file %s and changelogTableName %s", changelog, database.getDatabaseChangeLogTableName());
  
  return new Liquibase(changelog, resourceAccessor, database);
}

代码示例来源:origin: fi.testee/testeefi-liquibase

private void applyChangelog(
      final Connection c,
      final String contexts,
      final ResourceAccessor resourceAccessor,
      final String changelogFile
  ) throws LiquibaseException {
    liquibase.Liquibase liquibase = null;
    final Database database = DatabaseFactory.getInstance()
        .findCorrectDatabaseImplementation(new JdbcConnection(c));
    liquibase = new liquibase.Liquibase(changelogFile, resourceAccessor, database);
    liquibase.update(contexts);
  }
}

代码示例来源:origin: org.apache.polygene.libraries/org.apache.polygene.library.sql-liquibase

@Override
public Liquibase newConnectedLiquibase() throws SQLException, LiquibaseException
{
  config.refresh();
  DatabaseConnection dbConnection = new JdbcConnection( dataSource.get().getConnection() );
  return new Liquibase( config.get().changeLog().get(),
             new ClassLoaderResourceAccessor(),
             dbConnection );
}

代码示例来源:origin: apache/attic-polygene-java

@Override
public Liquibase newConnectedLiquibase() throws SQLException, LiquibaseException
{
  config.refresh();
  DatabaseConnection dbConnection = new JdbcConnection( dataSource.get().getConnection() );
  return new Liquibase( config.get().changeLog().get(),
             new ClassLoaderResourceAccessor(),
             dbConnection );
}

代码示例来源:origin: org.slinkyframework.environment/slinky-environment-builder-liquibase

public void setUp(LiquibaseBuildDefinition definition) {
  try {
    Connection con = getNewConnection(definition);
    Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(con));
    ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
    liquibase = new Liquibase(definition.getChangeLogFile(), resourceAccessor, database);
    LOGGER.info("Setting up database {} on {}", definition.getName(), hostname);
    liquibase.update("");
    closeConnectionQuietly(con);
  } catch (LiquibaseException | SQLException e) {
    throw new EnvironmentBuilderException("Database setup has failed", e);
  }
}

代码示例来源:origin: org.keycloak/keycloak-model-jpa

@Override
public Liquibase getLiquibaseForCustomUpdate(Connection connection, String defaultSchema, String changelogLocation, ClassLoader classloader, String changelogTableName) throws LiquibaseException {
  Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
  if (defaultSchema != null) {
    database.setDefaultSchemaName(defaultSchema);
  }
  ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor(classloader);
  database.setDatabaseChangeLogTableName(changelogTableName);
  logger.debugf("Using changelog file %s and changelogTableName %s", changelogLocation, database.getDatabaseChangeLogTableName());
  return new Liquibase(changelogLocation, resourceAccessor, database);
}

代码示例来源:origin: com.walmartlabs.concord.server/concord-server-db

private static void migrateDb(Connection conn, String logPath, String logTable, String lockTable) throws Exception {
  LogFactory.getInstance().setDefaultLoggingLevel(LogLevel.WARNING);
  Database db = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(conn));
  db.setDatabaseChangeLogTableName(logTable);
  db.setDatabaseChangeLogLockTableName(lockTable);
  Liquibase lb = new Liquibase(logPath, new ClassLoaderResourceAccessor(), db);
  lb.update((String) null);
}

代码示例来源:origin: liimaorg/liima

@Test
public void shouldLoadInitialDataSetInEmptyDatabase() throws LiquibaseException, SQLException, ClassNotFoundException {
  // given
  Class.forName("org.h2.Driver");
  conn = DriverManager.getConnection("jdbc:h2:mem:testdata", "sa", "");
  database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(conn));
  Liquibase liquibase = new Liquibase("liquibase/auto.db.changelog-initialrun.xml", new ClassLoaderResourceAccessor(), database);
  //when
  liquibase.update(new Contexts(), new LabelExpression());
  // then must not fail
  if(conn !=null) {
    conn.close();
  }
}

代码示例来源:origin: com.hubspot/BlazarData

private static void initializeEmptyTables() throws Exception {
 try (Connection connection = getConnection()) {
  ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
  JdbcConnection jdbcConnection = new JdbcConnection(connection);
  Liquibase liquibase = new Liquibase("schema.sql", resourceAccessor, jdbcConnection);
  liquibase.update(new Contexts());
 }
}

代码示例来源:origin: com.hubspot/SingularityService

@Before
public void createTestData() throws Exception {
 Handle handle = dbiProvider.get().open();
 Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(handle.getConnection()));
 Liquibase liquibase = new Liquibase("singularity_test.sql", new FileSystemResourceAccessor(), database);
 liquibase.update((String) null);
 try {
  database.close();
 } catch (Throwable t) {
 }
 handle.close();
}

相关文章