Java Code Examples for liquibase.resource.FileSystemResourceAccessor

The following examples show how to use liquibase.resource.FileSystemResourceAccessor. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: flux   Source File:    License: Apache License 2.0 6 votes vote down vote up
public void migrate(String dbName) {
    try {
        Configuration configuration = yamlConfiguration.subset(dbName + ".Hibernate");
        Properties properties = new Properties();
        properties.put("user", configuration.getProperty("hibernate.connection.username"));
        properties.put("password", configuration.getProperty("hibernate.connection.password"));
        String url = (String) configuration.getProperty("hibernate.connection.url");
        java.sql.Connection connection = DriverManager.getConnection(url, properties);
        Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
        ClassLoader classLoader = getClass().getClassLoader();
        File file = new File(classLoader.getResource(dbName +  "/migrations.xml").getFile());
        Liquibase liquibase = new Liquibase(file.getCanonicalPath(), new FileSystemResourceAccessor(), database);
        liquibase.update(new Contexts());
    } catch (Exception e) {
        System.err.println("Unable to perform database migration.");
Example 2
Source Project: modeldb   Source File:    License: Apache License 2.0 5 votes vote down vote up
private static void createTablesLiquibaseMigration(MetadataSources metaDataSrc)
    throws LiquibaseException, SQLException, InterruptedException {
  // Get database connection
  try (Connection con =
      metaDataSrc.getServiceRegistry().getService(ConnectionProvider.class).getConnection()) {
    JdbcConnection jdbcCon = new JdbcConnection(con);

    // Overwrite default liquibase table names by custom
    GlobalConfiguration liquibaseConfiguration =

    // Initialize Liquibase and run the update
    Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(jdbcCon);
    String rootPath = System.getProperty(ModelDBConstants.userDir);
    rootPath = rootPath + "\\src\\main\\resources\\liquibase\\db-changelog-1.0.xml";
    Liquibase liquibase = new Liquibase(rootPath, new FileSystemResourceAccessor(), database);

    boolean liquibaseExecuted = false;
    while (!liquibaseExecuted) {
      try {
        liquibase.update(new Contexts(), new LabelExpression());
        liquibaseExecuted = true;
      } catch (LockException ex) {
            "ModelDBHibernateUtil createTablesLiquibaseMigration() getting LockException ", ex);
Example 3
Source Project: Singularity   Source File:    License: Apache License 2.0 5 votes vote down vote up
public void setup() throws Exception {
  singularityTestModule = new SingularityTestModule(useDBTests, customConfigSetup);

  if (useDBTests) {
    Handle handle = dbiProvider.get().open();

    Database database = DatabaseFactory
      .findCorrectDatabaseImplementation(new JdbcConnection(handle.getConnection()));

    Liquibase liquibase = new Liquibase(
      new FileSystemResourceAccessor(),
    liquibase.update((String) null);

    try {
    } catch (Throwable t) {}
Example 4
Source Project: aerogear-unifiedpush-server   Source File:    License: Apache License 2.0 4 votes vote down vote up
private void initResourceAccessor() {
    String baseDir = "target/classes/liquibase";
    resourceAccessor = new FileSystemResourceAccessor(baseDir);
Example 5
Source Project: hmdm-server   Source File:    License: Apache License 2.0 2 votes vote down vote up
 * <p>Gets the resource accessor to be uused for loading the change log file.</p>
 * @return a resource accessor for change log file.
protected ResourceAccessor getResourceAccessor() {
    return new FileSystemResourceAccessor();