liquibase.database.DatabaseConnection Java Examples
The following examples show how to use
liquibase.database.DatabaseConnection.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GeometryColumnsUtilsTest.java From liquibase-spatial with Apache License 2.0 | 6 votes |
@DataProvider public Object[][] geometryColumnsExistsTestData() throws SQLException { // Create an H2 database instance without geometry_columns table. final Database noGeometryColumnsDatabase = new H2Database(); noGeometryColumnsDatabase.setConnection(new JdbcConnection(DriverManager .getConnection("jdbc:h2:mem:target/noGeometryColumns"))); final Database geometryColumnsDatabase = new H2Database(); Connection connection = DriverManager .getConnection("jdbc:h2:mem:target/geometryColumns"); DatabaseConnection conn = new JdbcConnection(connection); geometryColumnsDatabase.setConnection(conn); Statement statement = connection.createStatement(); statement .execute("CREATE TABLE geometry_columns (f_table_schema VARCHAR(128), " + "f_table_name VARCHAR(128), f_geometry_column VARCHAR(128), coord_dimension INT, " + "srid INT, type VARCHAR(30))"); statement.close(); return new Object[][] { new Object[] { noGeometryColumnsDatabase, false }, new Object[] { geometryColumnsDatabase, true } }; }
Example #2
Source File: AbstractPerconaChangeTest.java From liquibase-percona with Apache License 2.0 | 6 votes |
@BeforeEach public void setup() { System.setProperty(Configuration.LIQUIBASE_PASSWORD, "root"); database = new MySQLDatabase(); database.setLiquibaseSchemaName("testdb"); DatabaseConnection conn = new MockDatabaseConnection("jdbc:mysql://user@localhost:3306/testdb", "user@localhost"); database.setConnection(conn); JdbcExecutor executor = new JdbcExecutor(); executor.setDatabase(database); ExecutorService.getInstance().setExecutor(database, executor); PTOnlineSchemaChangeStatement.available = true; PTOnlineSchemaChangeStatement.perconaToolkitVersion = null; System.setProperty(Configuration.FAIL_IF_NO_PT, "false"); System.setProperty(Configuration.NO_ALTER_SQL_DRY_MODE, "false"); System.setProperty(Configuration.SKIP_CHANGES, ""); PerconaForeignKeyService.getInstance().disable(); setupChange(change); }
Example #3
Source File: FormEngineConfiguration.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void initDbSchema() { try { DatabaseConnection connection = new JdbcConnection(dataSource.getConnection()); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection); database.setDatabaseChangeLogTableName(LIQUIBASE_CHANGELOG_PREFIX+database.getDatabaseChangeLogTableName()); database.setDatabaseChangeLogLockTableName(LIQUIBASE_CHANGELOG_PREFIX+database.getDatabaseChangeLogLockTableName()); if (StringUtils.isNotEmpty(databaseSchema)) { database.setDefaultSchemaName(databaseSchema); database.setLiquibaseSchemaName(databaseSchema); } if (StringUtils.isNotEmpty(databaseCatalog)) { database.setDefaultCatalogName(databaseCatalog); database.setLiquibaseCatalogName(databaseCatalog); } Liquibase liquibase = new Liquibase("org/activiti/form/db/liquibase/activiti-form-db-changelog.xml", new ClassLoaderResourceAccessor(), database); if (DB_SCHEMA_UPDATE_DROP_CREATE.equals(databaseSchemaUpdate)) { logger.debug("Dropping and creating schema FORM"); liquibase.dropAll(); liquibase.update("form"); } else if (DB_SCHEMA_UPDATE_TRUE.equals(databaseSchemaUpdate)) { logger.debug("Updating schema FORM"); liquibase.update("form"); } else if (DB_SCHEMA_UPDATE_FALSE.equals(databaseSchemaUpdate)) { logger.debug("Validating schema FORM"); liquibase.validate(); } } catch (Exception e) { throw new ActivitiFormException("Error initialising form data schema", e); } }
Example #4
Source File: LiquibaseH2AsSAIT.java From liquibase-spatial with Apache License 2.0 | 5 votes |
/** * @see liquibase.ext.spatial.LiquibaseIT#createLiquibase(java.lang.String, * liquibase.resource.ResourceAccessor, liquibase.database.DatabaseConnection) */ @Override protected Liquibase createLiquibase(final String changeLogFile, final ResourceAccessor resourceAccessor, final DatabaseConnection databaseConnection) throws LiquibaseException { final Liquibase liquibase = super.createLiquibase(changeLogFile, resourceAccessor, databaseConnection); liquibase.getDatabase().setDefaultSchemaName(getUserName()); return liquibase; }
Example #5
Source File: LiquibasePostgreSQLIT.java From liquibase-spatial with Apache License 2.0 | 5 votes |
/** * @see liquibase.ext.spatial.LiquibaseIT#createLiquibase(java.lang.String, * liquibase.resource.ResourceAccessor, liquibase.database.DatabaseConnection) */ @Override protected Liquibase createLiquibase(final String changeLogFile, final ResourceAccessor resourceAccessor, final DatabaseConnection databaseConnection) throws LiquibaseException { final Liquibase liquibase = super.createLiquibase(changeLogFile, resourceAccessor, databaseConnection); liquibase.getDatabase().setDefaultSchemaName(getUserName()); return liquibase; }
Example #6
Source File: GeometryColumnsUtils.java From liquibase-spatial with Apache License 2.0 | 5 votes |
/** * Determines if the given column is in <code>GEOMETRY_COLUMNS</code>. * * @param database * the database to query. * @param schemaName * the schema name. * @param tableName * the table name. * @param columnName * the column name. * @return <code>true</code> if the column is a geometry column. */ public static boolean isGeometryColumn(final Database database, final String schemaName, final String tableName, final String columnName) { boolean isSpatialColumn = false; Statement jdbcStatement = null; try { if (geometryColumnsExists(database)) { final String query = "SELECT * FROM geometry_columns WHERE f_table_schema = '" + (schemaName == null ? database.getDefaultSchemaName() : schemaName) + "' AND f_table_name = '" + tableName + "' AND upper(f_geometry_column) = '" + columnName.toUpperCase() + "'"; final DatabaseConnection databaseConnection = database .getConnection(); final JdbcConnection jdbcConnection = (JdbcConnection) databaseConnection; jdbcStatement = jdbcConnection.getUnderlyingConnection() .createStatement(); final ResultSet rs = jdbcStatement.executeQuery(query); isSpatialColumn = rs.next(); } } catch (final SQLException e) { throw new UnexpectedLiquibaseException( "Failed to determine if the column to be dropped is a geometry column", e); } finally { if (jdbcStatement != null) { try { jdbcStatement.close(); } catch (final SQLException ignore) { } } } return isSpatialColumn; }
Example #7
Source File: GeometryColumnsUtils.java From liquibase-spatial with Apache License 2.0 | 5 votes |
/** * Determines if the given table is in <code>GEOMETRY_COLUMNS</code> and, * therefore, has a geometry column. * * @param database * the database to query. * @param schemaName * the schema name. * @param tableName * the table name to check. * @return <code>true</code> if the table has a geometry column. */ public static boolean hasGeometryColumn(final Database database, final String schemaName, final String tableName) { boolean isSpatialColumn = false; Statement jdbcStatement = null; try { if (geometryColumnsExists(database)) { final String query = "SELECT * FROM geometry_columns WHERE f_table_schema = '" + (schemaName == null ? database.getDefaultSchemaName() : schemaName) + "' AND f_table_name = '" + tableName + "'"; final DatabaseConnection databaseConnection = database .getConnection(); final JdbcConnection jdbcConnection = (JdbcConnection) databaseConnection; jdbcStatement = jdbcConnection.getUnderlyingConnection() .createStatement(); final ResultSet rs = jdbcStatement.executeQuery(query); isSpatialColumn = rs.next(); } } catch (final SQLException e) { throw new UnexpectedLiquibaseException( "Failed to determine if the table has a geometry column", e); } finally { if (jdbcStatement != null) { try { jdbcStatement.close(); } catch (final SQLException ignore) { } } } return isSpatialColumn; }
Example #8
Source File: PTOnlineSchemaChangeStatementTest.java From liquibase-percona with Apache License 2.0 | 5 votes |
@BeforeEach public void setup() { System.setProperty(Configuration.LIQUIBASE_PASSWORD, "root"); database = new MySQLDatabase(); database.setLiquibaseSchemaName("testdb"); DatabaseConnection conn = new MockDatabaseConnection("jdbc:mysql://user@localhost:3306/testdb", "user@localhost"); database.setConnection(conn); }
Example #9
Source File: LiquibaseService.java From attic-polygene-java with Apache License 2.0 | 5 votes |
@Override public Liquibase newConnectedLiquibase() throws SQLException, LiquibaseException { config.refresh(); DatabaseConnection dbConnection = new JdbcConnection( dataSource.get().getConnection() ); return new Liquibase( config.get().changeLog().get(), new ClassLoaderResourceAccessor(), dbConnection ); }
Example #10
Source File: DbSchemaDrop.java From flowable-engine with Apache License 2.0 | 5 votes |
public static void main(String[] args) { try { EventRegistryEngine eventRegistryEngine = EventRegistryEngines.getDefaultEventRegistryEngine(); EventRegistryEngineConfiguration eventRegistryEngineConfiguration = eventRegistryEngine.getEventRegistryEngineConfiguration(); DataSource dataSource = eventRegistryEngineConfiguration.getDataSource(); DatabaseConnection connection = new JdbcConnection(dataSource.getConnection()); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection); database.setDatabaseChangeLogTableName(EventRegistryEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogTableName()); database.setDatabaseChangeLogLockTableName(EventRegistryEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogLockTableName()); if (StringUtils.isNotEmpty(eventRegistryEngineConfiguration.getDatabaseSchema())) { database.setDefaultSchemaName(eventRegistryEngineConfiguration.getDatabaseSchema()); database.setLiquibaseSchemaName(eventRegistryEngineConfiguration.getDatabaseSchema()); } if (StringUtils.isNotEmpty(eventRegistryEngineConfiguration.getDatabaseCatalog())) { database.setDefaultCatalogName(eventRegistryEngineConfiguration.getDatabaseCatalog()); database.setLiquibaseCatalogName(eventRegistryEngineConfiguration.getDatabaseCatalog()); } Liquibase liquibase = new Liquibase("org/flowable/eventregistry/db/liquibase/flowable-eventregistry-db-changelog.xml", new ClassLoaderResourceAccessor(), database); liquibase.dropAll(); liquibase.getDatabase().close(); } catch (Exception e) { e.printStackTrace(); } }
Example #11
Source File: DbSchemaDrop.java From flowable-engine with Apache License 2.0 | 5 votes |
public static void main(String[] args) { try { ContentEngine contentEngine = ContentEngines.getDefaultContentEngine(); DataSource dataSource = contentEngine.getContentEngineConfiguration().getDataSource(); DatabaseConnection connection = new JdbcConnection(dataSource.getConnection()); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection); database.setDatabaseChangeLogTableName(ContentEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogTableName()); database.setDatabaseChangeLogLockTableName(ContentEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogLockTableName()); if (StringUtils.isNotEmpty(contentEngine.getContentEngineConfiguration().getDatabaseSchema())) { database.setDefaultSchemaName(contentEngine.getContentEngineConfiguration().getDatabaseSchema()); database.setLiquibaseSchemaName(contentEngine.getContentEngineConfiguration().getDatabaseSchema()); } if (StringUtils.isNotEmpty(contentEngine.getContentEngineConfiguration().getDatabaseCatalog())) { database.setDefaultCatalogName(contentEngine.getContentEngineConfiguration().getDatabaseCatalog()); database.setLiquibaseCatalogName(contentEngine.getContentEngineConfiguration().getDatabaseCatalog()); } Liquibase liquibase = new Liquibase("org/flowable/content/db/liquibase/flowable-content-db-changelog.xml", new ClassLoaderResourceAccessor(), database); liquibase.dropAll(); liquibase.getDatabase().close(); } catch (Exception e) { e.printStackTrace(); } }
Example #12
Source File: DbSchemaDrop.java From flowable-engine with Apache License 2.0 | 5 votes |
public static void main(String[] args) { try { FormEngine formEngine = FormEngines.getDefaultFormEngine(); DataSource dataSource = formEngine.getFormEngineConfiguration().getDataSource(); DatabaseConnection connection = new JdbcConnection(dataSource.getConnection()); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection); database.setDatabaseChangeLogTableName(FormEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogTableName()); database.setDatabaseChangeLogLockTableName(FormEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogLockTableName()); if (StringUtils.isNotEmpty(formEngine.getFormEngineConfiguration().getDatabaseSchema())) { database.setDefaultSchemaName(formEngine.getFormEngineConfiguration().getDatabaseSchema()); database.setLiquibaseSchemaName(formEngine.getFormEngineConfiguration().getDatabaseSchema()); } if (StringUtils.isNotEmpty(formEngine.getFormEngineConfiguration().getDatabaseCatalog())) { database.setDefaultCatalogName(formEngine.getFormEngineConfiguration().getDatabaseCatalog()); database.setLiquibaseCatalogName(formEngine.getFormEngineConfiguration().getDatabaseCatalog()); } Liquibase liquibase = new Liquibase("org/flowable/form/db/liquibase/flowable-form-db-changelog.xml", new ClassLoaderResourceAccessor(), database); liquibase.dropAll(); liquibase.getDatabase().close(); } catch (Exception e) { e.printStackTrace(); } }
Example #13
Source File: DbScriptUtil.java From flowable-engine with Apache License 2.0 | 5 votes |
protected static void closeDatabase(Database database, DatabaseConnection databaseConnection) { try { database.close(); databaseConnection.close(); } catch (Exception e) { System.out.println("Error closing db connection " + e.getMessage()); } }
Example #14
Source File: DbScriptUtil.java From flowable-engine with Apache License 2.0 | 5 votes |
protected static DatabaseConnection createDbConnection() throws Exception { Properties properties = new Properties(); properties.load(DbScriptUtil.class.getClassLoader().getResourceAsStream("META-INF/flowable-admin/TEST-db.properties")); Connection connection = DriverManager.getConnection(properties.getProperty("spring.datasource.url"), properties.getProperty("spring.datasource.username"), properties.getProperty("spring.datasource.password")); DatabaseConnection databaseConnection = new JdbcConnection(connection); return databaseConnection; }
Example #15
Source File: DbSchemaDrop.java From flowable-engine with Apache License 2.0 | 5 votes |
public static void main(String[] args) { try { DmnEngine dmnEngine = DmnEngines.getDefaultDmnEngine(); DataSource dataSource = dmnEngine.getDmnEngineConfiguration().getDataSource(); DatabaseConnection connection = new JdbcConnection(dataSource.getConnection()); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection); database.setDatabaseChangeLogTableName(DmnEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogTableName()); database.setDatabaseChangeLogLockTableName(DmnEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogLockTableName()); if (StringUtils.isNotEmpty(dmnEngine.getDmnEngineConfiguration().getDatabaseSchema())) { database.setDefaultSchemaName(dmnEngine.getDmnEngineConfiguration().getDatabaseSchema()); database.setLiquibaseSchemaName(dmnEngine.getDmnEngineConfiguration().getDatabaseSchema()); } if (StringUtils.isNotEmpty(dmnEngine.getDmnEngineConfiguration().getDatabaseCatalog())) { database.setDefaultCatalogName(dmnEngine.getDmnEngineConfiguration().getDatabaseCatalog()); database.setLiquibaseCatalogName(dmnEngine.getDmnEngineConfiguration().getDatabaseCatalog()); } Liquibase liquibase = new Liquibase("org/flowable/dmn/db/liquibase/flowable-dmn-db-changelog.xml", new ClassLoaderResourceAccessor(), database); liquibase.dropAll(); liquibase.getDatabase().close(); } catch (Exception e) { e.printStackTrace(); } }
Example #16
Source File: DbSchemaDrop.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public static void main(String[] args) { try { FormEngine formEngine = FormEngines.getDefaultFormEngine(); DataSource dataSource = formEngine.getFormEngineConfiguration().getDataSource(); DatabaseConnection connection = new JdbcConnection(dataSource.getConnection()); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection); database.setDatabaseChangeLogTableName(FormEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX+database.getDatabaseChangeLogTableName()); database.setDatabaseChangeLogLockTableName(FormEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX+database.getDatabaseChangeLogLockTableName()); if (StringUtils.isNotEmpty(formEngine.getFormEngineConfiguration().getDatabaseSchema())) { database.setDefaultSchemaName(formEngine.getFormEngineConfiguration().getDatabaseSchema()); database.setLiquibaseSchemaName(formEngine.getFormEngineConfiguration().getDatabaseSchema()); } if (StringUtils.isNotEmpty(formEngine.getFormEngineConfiguration().getDatabaseCatalog())) { database.setDefaultCatalogName(formEngine.getFormEngineConfiguration().getDatabaseCatalog()); database.setLiquibaseCatalogName(formEngine.getFormEngineConfiguration().getDatabaseCatalog()); } Liquibase liquibase = new Liquibase("org/activiti/form/db/liquibase/activiti-form-db-changelog.xml", new ClassLoaderResourceAccessor(), database); liquibase.dropAll(); } catch (Exception e) { e.printStackTrace(); } }
Example #17
Source File: DbScriptUtil.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public static void dropSchema() throws Exception { System.out.println("Dropping schema"); DatabaseConnection databaseConnection = createDbConnection(); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(databaseConnection); Liquibase liquibase = new Liquibase("META-INF/liquibase/db-changelog.xml", new ClassLoaderResourceAccessor(), database); liquibase.dropAll(); closeDatabase(database, databaseConnection); }
Example #18
Source File: DbScriptUtil.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected static DatabaseConnection createDbConnection() throws Exception { Properties properties = new Properties(); properties.load(DbScriptUtil.class.getClassLoader().getResourceAsStream("META-INF/activiti-admin/TEST-db.properties")); Connection connection = DriverManager.getConnection(properties.getProperty("datasource.url"), properties.getProperty("datasource.username"), properties.getProperty("datasource.password")); DatabaseConnection databaseConnection = new JdbcConnection(connection); return databaseConnection; }
Example #19
Source File: DbScriptUtil.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected static void closeDatabase(Database database, DatabaseConnection databaseConnection) { try { database.close(); databaseConnection.close(); } catch (Exception e) { System.out.println("Error closing db connection " + e.getMessage()); } }
Example #20
Source File: DbScriptUtil.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public static void dropSchema() throws Exception { System.out.println("Dropping schema"); DatabaseConnection databaseConnection = createDbConnection(); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(databaseConnection); Liquibase liquibase = new Liquibase("META-INF/liquibase/db-changelog-onpremise.xml", new ClassLoaderResourceAccessor(), database); liquibase.dropAll(); closeDatabase(database, databaseConnection); }
Example #21
Source File: DbScriptUtil.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected static DatabaseConnection createDbConnection() throws Exception { Properties properties = new Properties(); properties.load(DbScriptUtil.class.getClassLoader().getResourceAsStream("META-INF/activiti-app-test/TEST-db.properties")); Connection connection = DriverManager.getConnection(properties.getProperty("datasource.url"), properties.getProperty("datasource.username"), properties.getProperty("datasource.password")); DatabaseConnection databaseConnection = new JdbcConnection(connection); return databaseConnection; }
Example #22
Source File: DbScriptUtil.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected static void closeDatabase(Database database, DatabaseConnection databaseConnection) { try { database.close(); databaseConnection.close(); } catch (Exception e) { System.out.println("Error closing db connection " + e.getMessage()); } }
Example #23
Source File: DmnEngineConfiguration.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void initDbSchema() { try { DatabaseConnection connection = new JdbcConnection(dataSource.getConnection()); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection); database.setDatabaseChangeLogTableName(LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogTableName()); database.setDatabaseChangeLogLockTableName(LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogLockTableName()); if (StringUtils.isNotEmpty(databaseSchema)) { database.setDefaultSchemaName(databaseSchema); database.setLiquibaseSchemaName(databaseSchema); } if (StringUtils.isNotEmpty(databaseCatalog)) { database.setDefaultCatalogName(databaseCatalog); database.setLiquibaseCatalogName(databaseCatalog); } Liquibase liquibase = new Liquibase("org/activiti/dmn/db/liquibase/activiti-dmn-db-changelog.xml", new ClassLoaderResourceAccessor(), database); if (DB_SCHEMA_UPDATE_DROP_CREATE.equals(databaseSchemaUpdate)) { logger.debug("Dropping and creating schema DMN"); liquibase.dropAll(); liquibase.update("dmn"); } else if (DB_SCHEMA_UPDATE_TRUE.equals(databaseSchemaUpdate)) { logger.debug("Updating schema DMN"); liquibase.update("dmn"); } else if (DB_SCHEMA_UPDATE_FALSE.equals(databaseSchemaUpdate)) { logger.debug("Validating schema DMN"); liquibase.validate(); } } catch (Exception e) { throw new ActivitiDmnException("Error initialising dmn data model"); } }
Example #24
Source File: DbSchemaDrop.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public static void main(String[] args) { try { DmnEngine dmnEngine = DmnEngines.getDefaultDmnEngine(); DataSource dataSource = dmnEngine.getDmnEngineConfiguration().getDataSource(); DatabaseConnection connection = new JdbcConnection(dataSource.getConnection()); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection); database.setDatabaseChangeLogTableName(DmnEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX+database.getDatabaseChangeLogTableName()); database.setDatabaseChangeLogLockTableName(DmnEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX+database.getDatabaseChangeLogLockTableName()); if (StringUtils.isNotEmpty(dmnEngine.getDmnEngineConfiguration().getDatabaseSchema())) { database.setDefaultSchemaName(dmnEngine.getDmnEngineConfiguration().getDatabaseSchema()); database.setLiquibaseSchemaName(dmnEngine.getDmnEngineConfiguration().getDatabaseSchema()); } if (StringUtils.isNotEmpty(dmnEngine.getDmnEngineConfiguration().getDatabaseCatalog())) { database.setDefaultCatalogName(dmnEngine.getDmnEngineConfiguration().getDatabaseCatalog()); database.setLiquibaseCatalogName(dmnEngine.getDmnEngineConfiguration().getDatabaseCatalog()); } Liquibase liquibase = new Liquibase("org/activiti/dmn/db/liquibase/activiti-dmn-db-changelog.xml", new ClassLoaderResourceAccessor(), database); liquibase.dropAll(); } catch (Exception e) { e.printStackTrace(); } }
Example #25
Source File: DbScriptUtil.java From flowable-engine with Apache License 2.0 | 5 votes |
public static void dropSchema() throws Exception { System.out.println("Dropping schema"); DatabaseConnection databaseConnection = createDbConnection(); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(databaseConnection); Liquibase liquibase = new Liquibase("META-INF/liquibase/db-changelog.xml", new ClassLoaderResourceAccessor(), database); liquibase.dropAll(); closeDatabase(database, databaseConnection); }
Example #26
Source File: DatabaseConnectionUtil.java From liquibase-percona with Apache License 2.0 | 4 votes |
public DatabaseConnectionUtil(DatabaseConnection connection) { this.connection = connection; }
Example #27
Source File: HiveMetastoreDatabase.java From liquibase-impala with Apache License 2.0 | 4 votes |
@Override public boolean isCorrectDatabaseImplementation(DatabaseConnection databaseConnection) throws DatabaseException { return databaseProductName.equalsIgnoreCase(databaseConnection.getDatabaseProductName()); }
Example #28
Source File: HiveMetastoreDatabase.java From liquibase-impala with Apache License 2.0 | 4 votes |
@Override public void setConnection(DatabaseConnection conn) { setReservedWords(); super.setConnection(conn); }
Example #29
Source File: LiquibaseBasedSchemaManager.java From flowable-engine with Apache License 2.0 | 4 votes |
protected Liquibase createLiquibaseInstance(LiquibaseDatabaseConfiguration databaseConfiguration) throws SQLException { Connection jdbcConnection = null; boolean closeConnection = false; try { CommandContext commandContext = Context.getCommandContext(); if (commandContext == null) { jdbcConnection = databaseConfiguration.getDataSource().getConnection(); closeConnection = true; } else { jdbcConnection = commandContext.getSession(DbSqlSession.class).getSqlSession().getConnection(); } // A commit is needed here, because one of the things that Liquibase does when acquiring its lock // is doing a rollback, which removes all changes done so far. // For most databases, this is not a problem as DDL statements are not transactional. // However for some (e.g. sql server), this would remove all previous statements, which is not wanted, // hence the extra commit here. if (!jdbcConnection.getAutoCommit()) { jdbcConnection.commit(); } DatabaseConnection connection = new JdbcConnection(jdbcConnection); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection); database.setDatabaseChangeLogTableName(changeLogPrefix + database.getDatabaseChangeLogTableName()); database.setDatabaseChangeLogLockTableName(changeLogPrefix + database.getDatabaseChangeLogLockTableName()); String databaseSchema = databaseConfiguration.getDatabaseSchema(); if (StringUtils.isNotEmpty(databaseSchema)) { database.setDefaultSchemaName(databaseSchema); database.setLiquibaseSchemaName(databaseSchema); } String databaseCatalog = databaseConfiguration.getDatabaseCatalog(); if (StringUtils.isNotEmpty(databaseCatalog)) { database.setDefaultCatalogName(databaseCatalog); database.setLiquibaseCatalogName(databaseCatalog); } return new Liquibase(changeLogFile, new ClassLoaderResourceAccessor(), database); } catch (Exception e) { // We only close the connection if an exception occurred, otherwise the Liquibase instance cannot be used if (jdbcConnection != null && closeConnection) { jdbcConnection.close(); } throw new FlowableException("Error creating " + context + " liquibase instance", e); } }
Example #30
Source File: PostgresPlusDatabase.java From keycloak with Apache License 2.0 | 4 votes |
@Override public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws DatabaseException { return POSTGRESPLUS_PRODUCT_NAME.equalsIgnoreCase(conn.getDatabaseProductName()); }