hi all,
is it possible to “generateChangeLog diffTypes=data” programatically? Because the Liquibase facade does not provide any method for
that task.
im using liquibase-2.0-rc7.jar and derby 10.3.1.4
actually, im doing the following
-
public class DatabaseExporterImpl implements DatabaseExporter {
private static final String DIFF_TYPES = “data”;
private ExceptionFactory exceptionFactory;
private String username;
private String password;
private String driverClassName;
private String author;
private String connectionURL;
@Override
public void exportTo(String filename) {
try {
ClassLoader classLoader = this.getClass().getClassLoader();
Database database = CommandLineUtils.createDatabaseObject(
classLoader, connectionURL, username, password,
driverClassName, null, null);
CommandLineUtils.doGenerateChangeLog(filename, database, null,
DIFF_TYPES, author, null, null);
} catch (LiquibaseException e) {
throw cannotExportDatabaseTo(filename, e);
} catch (IOException e) {
throw cannotExportDatabaseTo(filename, e);
} catch (ParserConfigurationException e) {
throw cannotExportDatabaseTo(filename, e);
}
}
private DataExporterException cannotExportDatabaseTo(String filename,
Throwable cause) {
Object[] args = new Object[] { filename };
MessageCode code = MessageCode.CANNOT_EXPORT_DATABASE;
return exceptionFactory.newInstanceFor(code, args, cause);
}
public void setConnectionURL(String connectionURL) {
this.connectionURL = connectionURL;
}
public void setUsername(String username) {
this.username = username;
}
public void setPassword(String password) {
this.password = password;
}
public void setDriverClassName(String driverClassName) {
this.driverClassName = driverClassName;
}
public void setAuthor(String author) {
this.author = author;
}
public void setExceptionFactory(ExceptionFactory factory) {
this.exceptionFactory = factory;
}
}
but IMO it’s just a hack
because after that i’m having problems with the changelog file, because it remains open (basically a stream remains open somewhere).
and i cannot compress the file.
so, is there a correct way to “generateChangeLog diffTypes=data” programatically?
thanks in advance.