use of liquibase.integration.commandline.CommandLineResourceAccessor in project xipki by xipki.
the class LiquibaseMain method init.
public void init(String logLevel, String logFile) throws Exception {
changeLogLevel(logLevel, logFile);
FileSystemResourceAccessor fsOpener = new FileSystemResourceAccessor();
ClassLoader classLoader = getClass().getClassLoader();
ResourceAccessor clOpener = new CommandLineResourceAccessor(classLoader);
String defaultSchemaName = dbConf.getSchema();
this.database = // resourceAccessor
CommandLineUtils.createDatabaseObject(// resourceAccessor
clOpener, dbConf.getUrl(), dbConf.getUsername(), dbConf.getPassword(), dbConf.getDriver(), // defaultCatalogName
(String) null, // defaultSchemaName
defaultSchemaName, // outputDefaultCatalog
false, // outputDefaultSchema
false, // databaseClass
(String) null, // driverPropertiesFile
(String) null, // propertyProviderClass
(String) null, // liquibaseCatalogName
(String) null, // liquibaseSchemaName
(String) null, // databaseChangeLogTableName
(String) null, // databaseChangeLogLockTableName
(String) null);
try {
CompositeResourceAccessor fileOpener = new CompositeResourceAccessor(fsOpener, clOpener);
DiffOutputControl diffOutputControl = new // includeCatalog
DiffOutputControl(// includeCatalog
false, // includeSchema
false, // includeTablespace
false, // schemaComparisons
null);
CompareControl.SchemaComparison[] finalSchemaComparisons;
finalSchemaComparisons = new CompareControl.SchemaComparison[] { new CompareControl.SchemaComparison(new CatalogAndSchema(null, defaultSchemaName), new CatalogAndSchema(null, defaultSchemaName)) };
for (CompareControl.SchemaComparison schema : finalSchemaComparisons) {
diffOutputControl.addIncludedSchema(schema.getReferenceSchema());
diffOutputControl.addIncludedSchema(schema.getComparisonSchema());
}
this.liquibase = new Liquibase(changeLogFile, fileOpener, database);
} catch (Exception ex) {
try {
database.rollback();
database.close();
} catch (Exception ex2) {
LogFactory.getInstance().getLog().warning("problem closing connection", ex2);
}
throw ex;
}
}
Aggregations