本文整理汇总了Java中liquibase.exception.LiquibaseException类的典型用法代码示例。如果您正苦于以下问题:Java LiquibaseException类的具体用法?Java LiquibaseException怎么用?Java LiquibaseException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LiquibaseException类属于liquibase.exception包,在下文中一共展示了LiquibaseException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import liquibase.exception.LiquibaseException; //导入依赖的package包/类
/**
* Setup of test data: set attributes, purge and initialize test datbase
*/
@Before
public void setup() throws SQLException, LiquibaseException {
// Init jdbcTemplate
this.jdbcTemplate = new JdbcTemplate(datasource);
// Set test db properties
DriverManagerDataSource ds = (DriverManagerDataSource)datasource;
this.paasTestDbUrl = ds.getUrl();
this.paasTestDbUser = ds.getUsername();
this.paasTestDbPassword = ds.getPassword();
// purge test database
liquibaseWrapper.purgeDatabase(paasTestDbUrl, paasTestDbUser, paasTestDbPassword);
// init database state
liquibaseWrapper.applyChangeLog(paasTestDbUrl, paasTestDbUser, paasTestDbPassword, basicInitialChangeLofFile);
}
示例2: afterPropertiesSet
import liquibase.exception.LiquibaseException; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws LiquibaseException {
if (env.acceptsProfiles(Constants.SPRING_PROFILE_DEVELOPMENT)) {
taskExecutor.execute(() -> {
try {
log.warn("Starting Liquibase asynchronously, your database might not be ready at startup!");
initDb();
} catch (LiquibaseException e) {
log.error("Liquibase could not start correctly, your database is NOT ready: {}", e.getMessage(), e);
}
});
} else {
log.debug("Starting Liquibase synchronously");
initDb();
}
}
示例3: afterPropertiesSet
import liquibase.exception.LiquibaseException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void afterPropertiesSet() throws Exception {
if (getDataSource() == null && getSchemas() == null) {
super.afterPropertiesSet();
} else {
if (getDataSource() == null && getSchemas() != null) {
throw new LiquibaseException("When schemas are defined you should also define a base dataSource");
}
if (getDataSource() != null) {
log.info("Schema based multitenancy enabled");
if (CollectionUtils.isEmpty(getSchemas())) {
log.warn("Schemas not defined, using defaultSchema only");
setSchemas(new ArrayList<>());
getSchemas().add(getDefaultSchema());
}
runOnAllSchemasXm();
}
}
}
示例4: runOnAllSchemasXm
import liquibase.exception.LiquibaseException; //导入依赖的package包/类
private void runOnAllSchemasXm() throws LiquibaseException {
for (String schema : getSchemas()) {
if (schema.equals("default")) {
schema = null;
}
log.info("Initializing Liquibase for schema {}", schema);
try {
SpringLiquibase liquibase = getXmSpringLiquibase(getDataSource());
liquibase.setDefaultSchema(schema);
liquibase.afterPropertiesSet();
log.info("Liquibase run for schema {}", schema);
} catch (Exception e) {
log.error("Failed to initialize Liquibase for schema {}", schema, e);
}
}
}
示例5: create
import liquibase.exception.LiquibaseException; //导入依赖的package包/类
/**
* Create database schema for tenant.
*
* @param tenant - the tenant
*/
public void create(Tenant tenant) {
StopWatch stopWatch = createStarted();
log.info("START - SETUP:CreateTenant:schema tenantKey={}", tenant.getTenantKey());
DatabaseUtil.createSchema(dataSource, tenant.getTenantKey());
log.info("STOP - SETUP:CreateTenant:schema tenantKey={}, time={}ms", tenant.getTenantKey(),
stopWatch.getTime());
try {
stopWatch.reset();
stopWatch.start();
log.info("START - SETUP:CreateTenant:liquibase tenantKey={}", tenant.getTenantKey());
SpringLiquibase liquibase = new SpringLiquibase();
liquibase.setResourceLoader(resourceLoader);
liquibase.setDataSource(dataSource);
liquibase.setChangeLog(CHANGE_LOG_PATH);
liquibase.setContexts(liquibaseProperties.getContexts());
liquibase.setDefaultSchema(tenant.getTenantKey());
liquibase.setDropFirst(liquibaseProperties.isDropFirst());
liquibase.setShouldRun(true);
liquibase.afterPropertiesSet();
log.info("STOP - SETUP:CreateTenant:liquibase tenantKey={}, time={}ms", tenant.getTenantKey(),
stopWatch.getTime());
} catch (LiquibaseException e) {
throw new RuntimeException("Can not migrate database for creation tenant " + tenant.getTenantKey(), e);
}
}
示例6: initDatabaseSchema
import liquibase.exception.LiquibaseException; //导入依赖的package包/类
private void initDatabaseSchema() throws SQLException, LiquibaseException {
if (config.hasKey("database.changelog")) {
ResourceAccessor resourceAccessor = new FileSystemResourceAccessor();
Database database = DatabaseFactory.getInstance().openDatabase(
config.getString("database.url"),
config.getString("database.user"),
config.getString("database.password"),
null, resourceAccessor);
Liquibase liquibase = new Liquibase(
config.getString("database.changelog"), resourceAccessor, database);
liquibase.clearCheckSums();
liquibase.update(new Contexts());
}
}
示例7: afterPropertiesSet
import liquibase.exception.LiquibaseException; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws LiquibaseException {
if (env.acceptsProfiles(Constants.SPRING_PROFILE_DEVELOPMENT, Constants.SPRING_PROFILE_HEROKU)) {
taskExecutor.execute(() -> {
try {
log.warn("Starting Liquibase asynchronously, your database might not be ready at startup!");
initDb();
} catch (LiquibaseException e) {
log.error("Liquibase could not start correctly, your database is NOT ready: {}", e.getMessage(), e);
}
});
} else {
log.debug("Starting Liquibase synchronously");
initDb();
}
}
示例8: afterPropertiesSet
import liquibase.exception.LiquibaseException; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws LiquibaseException {
if (!env.acceptsProfiles(Constants.SPRING_PROFILE_NO_LIQUIBASE)) {
if (env.acceptsProfiles(Constants.SPRING_PROFILE_DEVELOPMENT, Constants.SPRING_PROFILE_HEROKU)) {
taskExecutor.execute(() -> {
try {
log.warn("Starting Liquibase asynchronously, your database might not be ready at startup!");
initDb();
} catch (LiquibaseException e) {
log.error("Liquibase could not start correctly, your database is NOT ready: {}", e.getMessage(), e);
}
});
} else {
log.debug("Starting Liquibase synchronously");
initDb();
}
} else {
log.debug("Liquibase is disabled");
}
}
示例9: setUpClass
import liquibase.exception.LiquibaseException; //导入依赖的package包/类
@BeforeClass
public static void setUpClass() throws ParserConfigurationException, IOException, SAXException, SQLException, LiquibaseException {
ApplicationConfig config = ConfigurationBuilder.createBuilder().loadXMLConfiguration().getConfiguration();
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setJdbcUrl("jdbc:" + config.getDbUrl() + "/" + config.getDbName());
hikariConfig.setUsername(config.getDbUser());
hikariConfig.setPassword(config.getDbPassword());
hikariConfig.setMaximumPoolSize(config.getThreadLimit());
if(config.isDbIgnoreSSLWarn()) {
hikariConfig.addDataSourceProperty("useSSL", false);
}
dataSource = new HikariDataSource(hikariConfig);
Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(dataSource.getConnection()));
Liquibase liquibase = new Liquibase("db/changelog/db.changelog-master.yaml", new ClassLoaderResourceAccessor(), database);
liquibase.update(new Contexts(), new LabelExpression());
}
示例10: afterPropertiesSet
import liquibase.exception.LiquibaseException; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws LiquibaseException {
if (!env.acceptsProfiles(Constants.SPRING_PROFILE_NO_LIQUIBASE)) {
if (env.acceptsProfiles(Constants.SPRING_PROFILE_DEVELOPMENT, Constants.SPRING_PROFILE_HEROKU)) {
taskExecutor.execute(() -> {
try {
logger.warn("Starting Liquibase asynchronously, your database might not be ready at startup!");
initDb();
} catch (LiquibaseException e) {
logger.error("Liquibase could not start correctly, your database is NOT ready: {}", e.getMessage(), e);
}
});
} else {
logger.debug("Starting Liquibase synchronously");
initDb();
}
} else {
logger.debug("Liquibase is disabled");
}
}
示例11: afterPropertiesSet
import liquibase.exception.LiquibaseException; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws LiquibaseException {
if (!env.acceptsProfiles(SPRING_PROFILE_NO_LIQUIBASE)) {
if (env.acceptsProfiles(SPRING_PROFILE_DEVELOPMENT, SPRING_PROFILE_HEROKU)) {
taskExecutor.execute(() -> {
try {
logger.warn(STARTING_ASYNC_MESSAGE);
initDb();
} catch (LiquibaseException e) {
logger.error(EXCEPTION_MESSAGE, e.getMessage(), e);
}
});
} else {
logger.debug(STARTING_SYNC_MESSAGE);
initDb();
}
} else {
logger.debug(DISABLED_MESSAGE);
}
}
示例12: applyChangelog
import liquibase.exception.LiquibaseException; //导入依赖的package包/类
@Override
public void applyChangelog( Map<String, Object> parameters )
throws SQLException, LiquibaseException
{
Liquibase liquibase = null;
try
{
liquibase = newConnectedLiquibase();
for( Map.Entry<String, Object> entry : parameters.entrySet() )
{
liquibase.getChangeLogParameters().set( entry.getKey(), entry.getValue() );
}
liquibase.update( config.get().contexts().get() );
}
finally
{
if( liquibase != null )
{
liquibase.getDatabase().close();
}
}
}
示例13: createTables
import liquibase.exception.LiquibaseException; //导入依赖的package包/类
private void createTables(String changelog) {
Connection holdingConnection;
try {
ResourceAccessor resourceAccessor = new FileSystemResourceAccessor();
holdingConnection = getConnectionImpl(USER_NAME, getPostgresPassword());
JdbcConnection conn = new JdbcConnection(holdingConnection);
PostgresDatabase database = new PostgresDatabase();
database.setDefaultSchemaName("public");
database.setConnection(conn);
liquibase = new Liquibase(changelog, resourceAccessor, database);
liquibase.dropAll();
liquibase.update("test");
conn.close();
} catch (SQLException | LiquibaseException ex) {
LOG.error("Error during createTable step", ex);
throw new RuntimeException("Error during createTable step", ex);
}
}
示例14: afterPropertiesSet
import liquibase.exception.LiquibaseException; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws LiquibaseException {
// if (env.acceptsProfiles(Constants.SPRING_PROFILE_DEVELOPMENT, Constants.SPRING_PROFILE_HEROKU)) {
// taskExecutor.execute(() -> {
// try {
// log.warn("Starting Liquibase asynchronously, your database might not be ready at startup!");
// initDb();
// } catch (LiquibaseException e) {
// log.error("Liquibase could not start correctly, your database is NOT ready: {}", e.getMessage(), e);
// }
// });
// } else {
log.debug("Starting Liquibase synchronously");
initDb();
// }
}
示例15: forceUpdate
import liquibase.exception.LiquibaseException; //导入依赖的package包/类
public void forceUpdate() throws LiquibaseException {
ConfigurationProperty shouldRunProperty =
LiquibaseConfiguration.getInstance().getProperty(GlobalConfiguration.class, GlobalConfiguration.SHOULD_RUN);
if (!shouldRunProperty.getValue(Boolean.class)) {
// don't override the global configuraiton...
// LiquibaseConfiguration.getInstance().getConfiguration(GlobalConfiguration.class).setValue(GlobalConfiguration.SHOULD_RUN, true);
log.warn("Can't override GlobalConfiguraiton when forcing liquibase to run");
return;
}
if (!shouldRun) {
log.info("Liquibase forcing 'shouldRun' " + "property on Spring Liquibase Bean: " + getBeanName());
shouldRun = true;
}
super.afterPropertiesSet();
}