# is it possible to generateChangeLog diffTypes=data programatically?

**URL:** <https://forum.liquibase.org/t/is-it-possible-to-generatechangelog-difftypes-data-programatically/988>\
**Category:** General Discussion\
**Created:** [December 9, 2010, 7:51pm UTC](https://forum.liquibase.org/t/is-it-possible-to-generatechangelog-difftypes-data-programatically/988 "2010-12-09T19:51:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vonbecmann](https://avatars.discourse-cdn.com/v4/letter/v/919ad9/32.png) [@vonbecmann](https://forum.liquibase.org/u/vonbecmann)\
**Post date:** [December 9, 2010, 7:51pm UTC](https://forum.liquibase.org/t/is-it-possible-to-generatechangelog-difftypes-data-programatically/988/1 "2010-12-09T19:51:00Z")

</div>

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 {

&nbsp; &nbsp; private static final String DIFF\_TYPES = “data”;  
&nbsp; &nbsp; private ExceptionFactory exceptionFactory;  
&nbsp; &nbsp; private String username;  
&nbsp; &nbsp; private String password;  
&nbsp; &nbsp; private String driverClassName;  
&nbsp; &nbsp; private String author;  
&nbsp; &nbsp; private String connectionURL;

&nbsp; &nbsp; @Override  
&nbsp; &nbsp; public void exportTo(String filename) {  
try {

```
&nbsp; &nbsp; ClassLoader classLoader = this.getClass().getClassLoader();
&nbsp; &nbsp; Database database = CommandLineUtils.createDatabaseObject(
	&nbsp; &nbsp; classLoader, connectionURL, username, password,
	&nbsp; &nbsp; driverClassName, null, null);
&nbsp; &nbsp; CommandLineUtils.doGenerateChangeLog(filename, database, null,
	&nbsp; &nbsp; DIFF_TYPES, author, null, null);

} catch (LiquibaseException e) {
&nbsp; &nbsp; throw cannotExportDatabaseTo(filename, e);
} catch (IOException e) {
&nbsp; &nbsp; throw cannotExportDatabaseTo(filename, e);
} catch (ParserConfigurationException e) {
&nbsp; &nbsp; throw cannotExportDatabaseTo(filename, e);
}

```

&nbsp; &nbsp; }

&nbsp; &nbsp; private DataExporterException cannotExportDatabaseTo(String filename,  
&nbsp; &nbsp; Throwable cause) {  
Object[] args = new Object[] { filename };  
MessageCode code = MessageCode.CANNOT\_EXPORT\_DATABASE;  
return exceptionFactory.newInstanceFor(code, args, cause);  
&nbsp; &nbsp; }

&nbsp; &nbsp; public void setConnectionURL(String connectionURL) {  
this.connectionURL = connectionURL;  
&nbsp; &nbsp; }

&nbsp; &nbsp; public void setUsername(String username) {  
this.username = username;  
&nbsp; &nbsp; }

&nbsp; &nbsp; public void setPassword(String password) {  
this.password = password;  
&nbsp; &nbsp; }

&nbsp; &nbsp; public void setDriverClassName(String driverClassName) {  
this.driverClassName = driverClassName;  
&nbsp; &nbsp; }

&nbsp; &nbsp; public void setAuthor(String author) {  
this.author = author;  
&nbsp; &nbsp; }

&nbsp; &nbsp; public void setExceptionFactory(ExceptionFactory factory) {  
this.exceptionFactory = factory;  
&nbsp; &nbsp; }

}

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.

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [December 9, 2010, 7:51pm UTC](https://forum.liquibase.org/t/is-it-possible-to-generatechangelog-difftypes-data-programatically/988/2 "2010-12-09T19:51:00Z")

</div>

The main object for the diff/generateChangeLog support liquibase.diff.Diff.&nbsp; I’ll add a placeholder call to it from the Liquibase object to make calling it easier.

The idea idea you call Diff diff = new Diff(refDatabase, targetDatabase).&nbsp; YOu can then call DiffResult result = diff.compare() which will actually do the compare and generate an in-memory representation.&nbsp; The DiffResult object has methods to read the diff information and/or output it in different formats.

Nathan
