Hi,
Connection
c = null;
Database
database = null;
PrintWriter
pw = null;
File
file = null;
liquibase.Liquibase
liquibase = null;
contexts
= db+"."+user;
try {
pw = new PrintWriter(new FileWriter(file));
// Get connection
c = SQLManager.getInstance().getConnection(db, user, passwd);
// Get liquibase connection
database =
DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection©);
liquibase = new liquibase.Liquibase(new
DatabaseChangeLog(fsource), new FileSystemResourceAccessor(),
database);
// Run liquibase action
switch (realAction) {
case Constants.LIQUIBASE_ACTION_FUTUREROLLBACKSQL:
liquibase.futureRollbackSQL(pw);
break;
case Constants.LIQUIBASE_ACTION_UPDATESQL:
liquibase.update(contexts, pw);
break;
case Constants.LIQUIBASE_ACTION_UPDATE:
liquibase.update(contexts);
if (!c.getAutoCommit())
c.commit();
break;
default:
throw new RuntimeException("Action not implemented");
}
pw.close();
database.close();
c.close();
}
catch (IOException | SQLException | LiquibaseException e) {
throw new Exception(e.getMessage());
}
finally {
if (c != null) {
try {
c.close();
} catch (SQLException e) {
throw new RuntimeException(e.getClass() + ": "
-
e.getMessage());
}
}
}