Skip to content

Instantly share code, notes, and snippets.

@steinarb
Created October 21, 2019 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steinarb/b0ced17a56614d0f5e99a7307f4fb298 to your computer and use it in GitHub Desktop.
Save steinarb/b0ced17a56614d0f5e99a7307f4fb298 to your computer and use it in GitHub Desktop.
@Component(service=UkelonnDatabase.class, immediate=true)
public class UkelonnDatabaseProvider implements UkelonnDatabase {
@Activate
public void activate() {
createDatasource();
UkelonnLiquibase liquibase = new UkelonnLiquibase();
try(Connection connect = getConnection()) {
try {
liquibase.createInitialSchema(connect);
insertMockData();
liquibase.updateSchema(connect);
} finally {
// Liquibase sets Connection.autoCommit to false, set it back to true
connect.setAutoCommit(true);
}
} catch (Exception e) {
logError("Failed to create derby test database schema", e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment