• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Executor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中liquibase.executor.Executor的典型用法代码示例。如果您正苦于以下问题:Java Executor类的具体用法?Java Executor怎么用?Java Executor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Executor类属于liquibase.executor包,在下文中一共展示了Executor类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: tag

import liquibase.executor.Executor; //导入依赖的package包/类
@Override
    public void tag(final String tagString) throws DatabaseException {
        Database database = getDatabase();
        Executor executor = ExecutorService.getInstance().getExecutor(database);
        try {
            int totalRows = ExecutorService.getInstance().getExecutor(database).queryForInt(new SelectFromDatabaseChangeLogStatement(new ColumnConfig().setName("COUNT(*)", true)));
            if (totalRows == 0) {
                ChangeSet emptyChangeSet = new ChangeSet(String.valueOf(new Date().getTime()), "liquibase", false, false, "liquibase-internal", null, null, getDatabase().getObjectQuotingStrategy(), null);
                this.setExecType(emptyChangeSet, ChangeSet.ExecType.EXECUTED);
            }

//            Timestamp lastExecutedDate = (Timestamp) this.getExecutor().queryForObject(createChangeToTagSQL(), Timestamp.class);
            executor.execute(new TagDatabaseStatement(tagString));
            getDatabase().commit();

            if (this.ranChangeSetList != null) {
                ranChangeSetList.get(ranChangeSetList.size() - 1).setTag(tagString);
            }
        } catch (Exception e) {
            throw new DatabaseException(e);
        }
    }
 
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:23,代码来源:HiveStandardChangeLogHistoryService.java


示例2: generateStatements

import liquibase.executor.Executor; //导入依赖的package包/类
@Override
public SqlStatement[] generateStatements(final Database database)
{
	validateParameters();

	final Executor currentExecutor = ExecutorService.getInstance().getExecutor(database);

	if (startOrStop == START_OR_STOP.START)
	{
		startSuppressing(database, currentExecutor);
	}
	else if (startOrStop == START_OR_STOP.STOP)
	{
		stopSuppressing(database, currentExecutor);
	}
	else
	{
		throw new IllegalArgumentException("Unknown startOrStop value " + startOrStop.name());
	}

	return new SqlStatement[] {};
}
 
开发者ID:Jurrie,项目名称:liquibase-suppress-output,代码行数:23,代码来源:SuppressOutputChange.java


示例3: generateRollbackStatements

import liquibase.executor.Executor; //导入依赖的package包/类
@Override
public SqlStatement[] generateRollbackStatements(final Database database) throws RollbackImpossibleException
{
	validateParameters();

	final Executor currentExecutor = ExecutorService.getInstance().getExecutor(database);

	if (startOrStop == START_OR_STOP.START)
	{
		stopSuppressing(database, currentExecutor);
	}
	else if (startOrStop == START_OR_STOP.STOP)
	{
		startSuppressing(database, currentExecutor);
	}
	else
	{
		throw new IllegalArgumentException("Unknown startOrStop value " + startOrStop.name());
	}

	return new SqlStatement[] {};
}
 
开发者ID:Jurrie,项目名称:liquibase-suppress-output,代码行数:23,代码来源:SuppressOutputChange.java


示例4: tag

import liquibase.executor.Executor; //导入依赖的package包/类
/**
     * Tags the database changelog with the given string.
     */
    public void tag(String tagString) throws DatabaseException {
        Executor executor = ExecutorService.getInstance().getExecutor(this);
        try {
            int totalRows = ExecutorService.getInstance().getExecutor(this).queryForInt(new SelectFromDatabaseChangeLogStatement("COUNT(*)"));
            if (totalRows == 0) {
                ChangeSet emptyChangeSet = new ChangeSet(String.valueOf(new Date().getTime()), "liquibase", false, false, "liquibase-internal", null, null);
                this.markChangeSetExecStatus(emptyChangeSet, ChangeSet.ExecType.EXECUTED);
            }

//            Timestamp lastExecutedDate = (Timestamp) this.getExecutor().queryForObject(createChangeToTagSQL(), Timestamp.class);
            executor.execute(new TagDatabaseStatement(tagString));
            this.commit();

            getRanChangeSetList().get(getRanChangeSetList().size() - 1).setTag(tagString);
        } catch (Exception e) {
            throw new DatabaseException(e);
        }
    }
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:22,代码来源:AbstractDatabase.java


示例5: update

import liquibase.executor.Executor; //导入依赖的package包/类
public void update(String contexts, Writer output) throws LiquibaseException {
    contexts = StringUtils.trimToNull(contexts);
    changeLogParameters.setContexts(StringUtils.splitAndTrim(contexts, ","));

    Executor oldTemplate = ExecutorService.getInstance().getExecutor(database);
    LoggingExecutor loggingExecutor = new LoggingExecutor(ExecutorService.getInstance().getExecutor(database), output, database);
    ExecutorService.getInstance().setExecutor(database, loggingExecutor);

    outputHeader("Update Database Script");

    LockService lockService = LockService.getInstance(database);
    lockService.waitForLock();

    try {

        update(contexts);

        output.flush();
    } catch (IOException e) {
        throw new LiquibaseException(e);
    } finally {
        lockService.releaseLock();
    }

    ExecutorService.getInstance().setExecutor(database, oldTemplate);
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:27,代码来源:Liquibase.java


示例6: rollback

import liquibase.executor.Executor; //导入依赖的package包/类
public void rollback(int changesToRollback, String contexts, Writer output) throws LiquibaseException {
    contexts = StringUtils.trimToNull(contexts);
    changeLogParameters.setContexts(StringUtils.splitAndTrim(contexts, ","));

    Executor oldTemplate = ExecutorService.getInstance().getExecutor(database);
    ExecutorService.getInstance().setExecutor(database, new LoggingExecutor(ExecutorService.getInstance().getExecutor(database), output, database));

    outputHeader("Rollback " + changesToRollback + " Change(s) Script");

    rollback(changesToRollback, contexts);

    try {
        output.flush();
    } catch (IOException e) {
        throw new LiquibaseException(e);
    }
    ExecutorService.getInstance().setExecutor(database, oldTemplate);
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:19,代码来源:Liquibase.java


示例7: changeLogSync

import liquibase.executor.Executor; //导入依赖的package包/类
public void changeLogSync(String contexts, Writer output) throws LiquibaseException {
    contexts = StringUtils.trimToNull(contexts);
    changeLogParameters.setContexts(StringUtils.splitAndTrim(contexts, ","));

    LoggingExecutor outputTemplate = new LoggingExecutor(ExecutorService.getInstance().getExecutor(database), output, database);
    Executor oldTemplate = ExecutorService.getInstance().getExecutor(database);
    ExecutorService.getInstance().setExecutor(database, outputTemplate);

    outputHeader("SQL to add all changesets to database history table");

    changeLogSync(contexts);

    try {
        output.flush();
    } catch (IOException e) {
        throw new LiquibaseException(e);
    }

    ExecutorService.getInstance().setExecutor(database, oldTemplate);
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:21,代码来源:Liquibase.java


示例8: markNextChangeSetRan

import liquibase.executor.Executor; //导入依赖的package包/类
public void markNextChangeSetRan(String contexts, Writer output) throws LiquibaseException {
    contexts = StringUtils.trimToNull(contexts);
    changeLogParameters.setContexts(StringUtils.splitAndTrim(contexts, ","));


    LoggingExecutor outputTemplate = new LoggingExecutor(ExecutorService.getInstance().getExecutor(database), output, database);
    Executor oldTemplate = ExecutorService.getInstance().getExecutor(database);
    ExecutorService.getInstance().setExecutor(database, outputTemplate);

    outputHeader("SQL to add all changesets to database history table");

    markNextChangeSetRan(contexts);

    try {
        output.flush();
    } catch (IOException e) {
        throw new LiquibaseException(e);
    }

    ExecutorService.getInstance().setExecutor(database, oldTemplate);
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:22,代码来源:Liquibase.java


示例9: isDryRun

import liquibase.executor.Executor; //导入依赖的package包/类
/**
 * Determines whether *SQL (updateSQL/rollbackSQL) is executed or whether
 * the statements should be executed directly.
 * @param database the database
 * @return <code>true</code> if dry-run is enabled and the statements should *not* be executed.
 */
private static boolean isDryRun(Database database) {
    Executor executor = ExecutorService.getInstance().getExecutor(database);
    if (executor instanceof LoggingExecutor) {
        return true;
    }
    return false;
}
 
开发者ID:adangel,项目名称:liquibase-percona,代码行数:14,代码来源:PerconaChangeUtil.java


示例10: cleanDB

import liquibase.executor.Executor; //导入依赖的package包/类
public static void cleanDB() throws Exception {
	liquiBase = new Liquibase( changeLogFile, new ClassLoaderResourceAccessor(), jdbcConnection );
	liquiBase.dropAll();
	
	Executor executor = ExecutorService.getInstance().getExecutor( liquiBase.getDatabase() );
	ResultSet rs = null;
	try {
		rs = jdbcConnection.getMetaData().getTables( null, liquiBase.getDatabase().getDefaultSchemaName(), "%", new String[] { "MATERIALIZED VIEW" } );
		while ( rs.next() ) {
			executor.execute( new DropMaterializedViewStatement( rs.getString( "TABLE_NAME" ) ) );
		}
	} finally {
		closeSilently( rs );
	}
}
 
开发者ID:mrswadge,项目名称:liquibase-flexibleview,代码行数:16,代码来源:BaseTestCase.java


示例11: writeBody

import liquibase.executor.Executor; //导入依赖的package包/类
@Override
protected void writeBody(FileWriter fileWriter, Object object, List<Change> ranChanges, List<Change> changesToRun) throws IOException, DatabaseHistoryException, DatabaseException {

    Executor oldTemplate = ExecutorService.getInstance().getExecutor(database);
    LoggingExecutor loggingExecutor = new LoggingExecutor(ExecutorService.getInstance().getExecutor(database), fileWriter, database);
    ExecutorService.getInstance().setExecutor(database, loggingExecutor);

    try {
        if (changesToRun.size() == 0) {
            fileWriter.append("<b>NONE</b>");
        }

        fileWriter.append("<code><pre>");

        ChangeSet lastRunChangeSet = null;

        for (Change change : changesToRun) {
            ChangeSet thisChangeSet = change.getChangeSet();
            if (thisChangeSet.equals(lastRunChangeSet)) {
                continue;
            }
            lastRunChangeSet = thisChangeSet;
            String anchor = thisChangeSet.toString(false).replaceAll("\\W","_");
            fileWriter.append("<a name='").append(anchor).append("'/>");
            try {
                thisChangeSet.execute(databaseChangeLog, this.database);
            } catch (MigrationFailedException e) {
                fileWriter.append("EXECUTION ERROR: ").append(change.getChangeMetaData().getDescription()).append(": ").append(e.getMessage()).append("\n\n");
            }
        }
        fileWriter.append("</pre></code>");
    } finally {
        ExecutorService.getInstance().setExecutor(database, oldTemplate);
    }
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:36,代码来源:PendingSQLWriter.java


示例12: checkDatabaseChangeLogLockTable

import liquibase.executor.Executor; //导入依赖的package包/类
/**
 * This method will check the database ChangeLogLock table used to keep track of
 * if a machine is updating the database. If the table does not exist it will create one
 * otherwise it will not do anything besides outputting a log message.
 */
public void checkDatabaseChangeLogLockTable() throws DatabaseException {

    Executor executor = ExecutorService.getInstance().getExecutor(this);
    if (!hasDatabaseChangeLogLockTable()) {

        executor.comment("Create Database Lock Table");
        executor.execute(new CreateDatabaseChangeLogLockTableStatement());
        this.commit();
        LogFactory.getLogger().debug("Created database lock table with name: " + escapeTableName(getLiquibaseSchemaName(), getDatabaseChangeLogLockTableName()));
        this.hasDatabaseChangeLogLockTable = true;
    }
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:18,代码来源:AbstractDatabase.java


示例13: getViewDefinition

import liquibase.executor.Executor; //导入依赖的package包/类
@Override
public String getViewDefinition(String schemaName, String viewName) throws DatabaseException {
       GetViewDefinitionStatement statement = new GetViewDefinitionStatement(convertRequestedSchemaToSchema(schemaName), viewName);
       Executor executor = ExecutorService.getInstance().getExecutor(this);
       @SuppressWarnings("unchecked")
       List<String> definitionRows = (List<String>) executor.queryForList(statement, String.class);
       StringBuilder definition = new StringBuilder();
       for (String d : definitionRows) {
       	definition.append(d);
       }
       return definition.toString();
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:13,代码来源:SybaseDatabase.java


示例14: outputHeader

import liquibase.executor.Executor; //导入依赖的package包/类
private void outputHeader(String message) throws DatabaseException {
    Executor executor = ExecutorService.getInstance().getExecutor(database);
    executor.comment("*********************************************************************");
    executor.comment(message);
    executor.comment("*********************************************************************");
    executor.comment("Change Log: " + changeLogFile);
    executor.comment("Ran at: " + DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date()));
    executor.comment("Against: " + getDatabase().getConnection().getConnectionUserName() + "@" + getDatabase().getConnection().getURL());
    executor.comment("Liquibase version: " + LiquibaseUtil.getBuildVersion());
    executor.comment("*********************************************************************" + StreamUtil.getLineSeparator());
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:12,代码来源:Liquibase.java


示例15: test

import liquibase.executor.Executor; //导入依赖的package包/类
@Test
public void test() throws Exception {
	final List<String> expected = Arrays.asList( 
			"iftableexists", "iftablenotexists", "ifviewexists", "ifviewnotexists", 
			"ifindexexists1", "ifindexexists2", "ifindexnotexists1", "ifpkexists",
			"ifpknotexists", "iffkexists", "iffknotexists", "ifsequenceexists",
			"ifsequencenotexists"
	);
	Executor executor = ExecutorService.getInstance().getExecutor( liquiBase.getDatabase() );
	List<String> successes = executor.queryForList( new RawSqlStatement( "select * from testresults" ), String.class );
	assertTrue( successes.containsAll( expected ) );
}
 
开发者ID:mrswadge,项目名称:liquibase-oracle-preconditions,代码行数:13,代码来源:OraclePreconditionsTest.java


示例16: SuppressOutputExecutor

import liquibase.executor.Executor; //导入依赖的package包/类
public SuppressOutputExecutor(final Executor previousExecutor, final Database database)
{
	this.previousExecutor = previousExecutor;
	setDatabase(database);
}
 
开发者ID:Jurrie,项目名称:liquibase-suppress-output,代码行数:6,代码来源:SuppressOutputExecutor.java


示例17: getPreviousExecutor

import liquibase.executor.Executor; //导入依赖的package包/类
public Executor getPreviousExecutor()
{
	return previousExecutor;
}
 
开发者ID:Jurrie,项目名称:liquibase-suppress-output,代码行数:5,代码来源:SuppressOutputExecutor.java


示例18: futureRollbackSQL

import liquibase.executor.Executor; //导入依赖的package包/类
public void futureRollbackSQL(Integer count, String contexts, Writer output) throws LiquibaseException {
    contexts = StringUtils.trimToNull(contexts);
    changeLogParameters.setContexts(StringUtils.splitAndTrim(contexts, ","));

    LoggingExecutor outputTemplate = new LoggingExecutor(ExecutorService.getInstance().getExecutor(database), output, database);
    Executor oldTemplate = ExecutorService.getInstance().getExecutor(database);
    ExecutorService.getInstance().setExecutor(database, outputTemplate);

    outputHeader("SQL to roll back currently unexecuted changes");

    LockService lockService = LockService.getInstance(database);
    lockService.waitForLock();

    try {
        DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance().getParser(changeLogFile, resourceAccessor).parse(changeLogFile, changeLogParameters, resourceAccessor);
        checkDatabaseChangeLogTable(false, changeLog, contexts);
        changeLog.validate(database, contexts);

        ChangeLogIterator logIterator;
        if (count == null) {
            logIterator = new ChangeLogIterator(changeLog,
                    new NotRanChangeSetFilter(database.getRanChangeSetList()),
                    new ContextChangeSetFilter(contexts),
                    new DbmsChangeSetFilter(database));
        } else {
            ChangeLogIterator forwardIterator = new ChangeLogIterator(changeLog,
                    new NotRanChangeSetFilter(database.getRanChangeSetList()),
                    new ContextChangeSetFilter(contexts),
                    new DbmsChangeSetFilter(database),
                    new CountChangeSetFilter(count));
            final ListVisitor listVisitor = new ListVisitor();
            forwardIterator.run(listVisitor, database);

            logIterator = new ChangeLogIterator(changeLog,
                    new NotRanChangeSetFilter(database.getRanChangeSetList()),
                    new ContextChangeSetFilter(contexts),
                    new DbmsChangeSetFilter(database),
                    new ChangeSetFilter() {
                        public boolean accepts(ChangeSet changeSet) {
                            return listVisitor.getSeenChangeSets().contains(changeSet);
                        }
                    });
        }

        logIterator.run(new RollbackVisitor(database), database);
    } finally {
        lockService.releaseLock();
        ExecutorService.getInstance().setExecutor(database, oldTemplate);
    }

    try {
        output.flush();
    } catch (IOException e) {
        throw new LiquibaseException(e);
    }

}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:58,代码来源:Liquibase.java


示例19: generateChildren

import liquibase.executor.Executor; //导入依赖的package包/类
private void generateChildren(Database database) {
    // Make a new list
    childDropChanges = new ArrayList<DropForeignKeyConstraintChange>();

    Executor executor = ExecutorService.getInstance().getExecutor(database);

    FindForeignKeyConstraintsStatement sql = new FindForeignKeyConstraintsStatement(
            getBaseTableSchemaName(),
            getBaseTableName()
    );

    try {
        List<Map> results = executor.queryForList(sql);
        Set<String> handledConstraints = new HashSet<String>();

        if (results != null && results.size() > 0) {
            for (Map result : results) {
                String baseTableName =
                        (String) result.get(FindForeignKeyConstraintsStatement.RESULT_COLUMN_BASE_TABLE_NAME);
                String constraintName =
                        (String) result.get(FindForeignKeyConstraintsStatement.RESULT_COLUMN_CONSTRAINT_NAME);
                if (getBaseTableName().equalsIgnoreCase(baseTableName)) {
                    if( !handledConstraints.contains(constraintName)) {
                        DropForeignKeyConstraintChange dropForeignKeyConstraintChange =
                                new DropForeignKeyConstraintChange();

                        dropForeignKeyConstraintChange.setBaseTableSchemaName(getBaseTableSchemaName());
                        dropForeignKeyConstraintChange.setBaseTableName(baseTableName);
                        dropForeignKeyConstraintChange.setConstraintName(constraintName);

                        childDropChanges.add(dropForeignKeyConstraintChange);
                        handledConstraints.add(constraintName);
                    }
                } else {
                    throw new IllegalStateException("Expected to return only foreign keys for base table name: " +
                            getBaseTableName() + " and got results for table: " + baseTableName);
                }
            }
        }
    } catch (DatabaseException e) {
        throw new UnexpectedLiquibaseException("Failed to find foreign keys for table: " + getBaseTableName(), e);
    }
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:44,代码来源:DropAllForeignKeyConstraintsChange.java



注:本文中的liquibase.executor.Executor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DraconianValidationErrorHandler类代码示例发布时间:2022-05-23
下一篇:
Java XMLReaderManager类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap