当前位置: 首页>>代码示例>>Java>>正文


Java Database类代码示例

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


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

示例1: resourceInsert

import liquibase.database.Database; //导入依赖的package包/类
private List<SqlStatement> resourceInsert( String resourcePath, Database database)
	{
		final List <SqlStatement> sqlStatements;
		final String tableName;
		final InsertStatement insertStatement;
		final String contentType;
		//resourcePath = ResourceHelper.getResourceAddress(isFromGameResourceInput() ,getSetPath(), resourcePath.substring(1));
		tableName= "image_resource";
		contentType = getContentType(resourcePath);
		sqlStatements = new ArrayList <SqlStatement>();
		insertStatement =SQLStatementHelper.getDefaultInsertStatement(database, tableName); 
		insertStatement.addColumnValue("name", resourcePath);
		insertStatement.addColumnValue("hi_res_image_content_type", contentType);
		insertStatement.addColumnValue("hi_res_image_path", resourcePath);
		insertStatement.addColumnValue("lo_res_image_content_type", contentType);
		insertStatement.addColumnValue("lo_res_image_path", resourcePath);
		sqlStatements.add(insertStatement);
		return sqlStatements; 
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:20,代码来源:MultipleChoiceImageLoader.java

示例2: execute

import liquibase.database.Database; //导入依赖的package包/类
@Override
public void execute(Database arg0) throws CustomChangeException {
	log.info(this.getClass() + " is being executed");
	final List<String> list;
	final List<SqlStatement> transactions;
	list =getMultipleChoiceImageResources();

	Map<String, String> inputOuputImagesMap = inputToOutput(list);
		
	transactions = new ArrayList<SqlStatement>();
	Iterator<Entry<String, String>> it = inputOuputImagesMap.entrySet().iterator();
    while (it.hasNext()) {
        Entry<String,String> pair = it.next();
        it.remove(); // avoids a ConcurrentModificationException
		transactions.addAll(resourceInsert(pair.getValue(),arg0));
        
    }
		SQLStatementHelper.defaultDirtyExecuteAndCommit(arg0, transactions, log);
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:20,代码来源:MultipleChoiceImageLoader.java

示例3: execute

import liquibase.database.Database; //导入依赖的package包/类
@Override
public void execute(Database arg0) throws CustomChangeException {
	// TODO Auto-generated method stub
	// TODO Auto-generated method stub
	log.info(this.getClass().getName());
	ArrayList<SqlStatement> sqlStatements = new ArrayList<SqlStatement>();
	HashSet<Integer> records = parse();
	
	for (Integer exerciseId : records){
				InsertStatement insertStatement =new InsertStatement(arg0.getDefaultSchema().getCatalogName(), arg0.getDefaultSchema().getSchemaName(), "hang_man_game_container"); 
				insertStatement.addColumnValue("id", exerciseId);
				insertStatement.addColumnValue("name", exerciseId.toString());
				
				sqlStatements.add(insertStatement);
	}
	SQLStatementHelper.defaultExecuteAndCommit(arg0, sqlStatements, log);
	
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:19,代码来源:HangManGameContainerLoader.java

示例4: generateSql

import liquibase.database.Database; //导入依赖的package包/类
@Override
public Sql[] generateSql(RemoveChangeSetRanStatusStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    ChangeSet changeSet = statement.getChangeSet();
    String tmpTable = UUID.randomUUID().toString().replaceAll("-", "");
    String catalogName = database.getLiquibaseCatalogName();
    String schemaName = database.getDefaultSchemaName();
    String tableName = database.getDatabaseChangeLogTableName();
    CreateTableAsSelectStatement createTableAsSelectStatement = new CreateTableAsSelectStatement(catalogName, schemaName, tableName, tmpTable)
            .addColumnNames("ID", "AUTHOR", "FILENAME", "DATEEXECUTED", "ORDEREXECUTED", "EXECTYPE", "MD5SUM", "DESCRIPTION", "COMMENTS", "TAG", "LIQUIBASE", "CONTEXTS", "LABELS", "DEPLOYMENT_ID")
            .setWhereCondition(" NOT (" + database.escapeObjectName("ID", Column.class) + " = ? " +
                    "AND " + database.escapeObjectName("FILENAME", Column.class) + " = ?)")
            .addWhereParameters(changeSet.getId(), changeSet.getFilePath());

    return CustomSqlGenerator.generateSql(database,
            UserSessionSettings.syncDdlStart(),
            createTableAsSelectStatement,
            new DropTableStatement(catalogName, schemaName, tableName, false),
            new RenameTableStatement(catalogName, schemaName, tmpTable, tableName),
            UserSessionSettings.syncDdlStop());
}
 
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:21,代码来源:ImpalaRemoveChangeSetRanStatusGenerator.java

示例5: generateSql

import liquibase.database.Database; //导入依赖的package包/类
@Override
public Sql[] generateSql(LockDatabaseChangeLogStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    String catalogName = database.getLiquibaseCatalogName();
    String schemaName = database.getDefaultSchemaName();
    String tableName = database.getDatabaseChangeLogLockTableName();
    InsertStatement insertStatement = new InsertStatement(catalogName, schemaName, tableName)
            .addColumnValue("ID", 1)
            .addColumnValue("LOCKED", Boolean.TRUE)
            .addColumnValue("LOCKEDBY", hostname + " [" + hostaddress + "]")
            .addColumnValue("LOCKGRANTED", DateTimeUtils.getCurrentTS("yyyy-MM-dd HH:mm:ss"));

    return CustomSqlGenerator.generateSql(database,
            UserSessionSettings.syncDdlStart(),
            new TruncateTableStatement(catalogName, schemaName, tableName),
            insertStatement,
            UserSessionSettings.syncDdlStop());
}
 
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:18,代码来源:ImpalaLockDatabaseChangeLogGenerator.java

示例6: generateSql

import liquibase.database.Database; //导入依赖的package包/类
@Override
public Sql[] generateSql(RemoveChangeSetRanStatusStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    ChangeSet changeSet = statement.getChangeSet();
    String tmpTable = UUID.randomUUID().toString().replaceAll("-", "");
    String catalogName = database.getLiquibaseCatalogName();
    String schemaName = database.getDefaultSchemaName();
    String tableName = database.getDatabaseChangeLogTableName();
    CreateTableAsSelectStatement createTableAsSelectStatement = new CreateTableAsSelectStatement(catalogName, schemaName, tableName, tmpTable)
            .addColumnNames("ID", "AUTHOR", "FILENAME", "DATEEXECUTED", "ORDEREXECUTED", "EXECTYPE", "MD5SUM", "DESCRIPTION", "COMMENTS", "TAG", "LIQUIBASE", "CONTEXTS", "LABELS", "DEPLOYMENT_ID")
            .setWhereCondition(database.escapeObjectName("ID", Column.class) + " != ? " +
                    "AND " + database.escapeObjectName("FILENAME", Column.class) + " != ?")
            .addWhereParameters(changeSet.getId(), changeSet.getFilePath());

    return CustomSqlGenerator.generateSql(database,
            createTableAsSelectStatement,
            new DropTableStatement(catalogName, schemaName, tableName, false),
            new RenameTableStatement(catalogName, schemaName, tmpTable, tableName));
}
 
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:19,代码来源:HiveRemoveChangeSetRanStatusGenerator.java

示例7: generateSql

import liquibase.database.Database; //导入依赖的package包/类
@Override
public Sql[] generateSql(CreateDatabaseChangeLogTableStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    String TypeNameChar = "STRING";

    CreateTableStatement createTableStatement = new CreateTableStatement(database.getLiquibaseCatalogName(), database.getLiquibaseSchemaName(), database.getDatabaseChangeLogTableName())
            .setTablespace(database.getLiquibaseTablespaceName())
            .addColumn("ID", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
            .addColumn("AUTHOR", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
            .addColumn("FILENAME", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
            .addColumn("DATEEXECUTED", DataTypeFactory.getInstance().fromDescription("TIMESTAMP", database))
            .addColumn("ORDEREXECUTED", DataTypeFactory.getInstance().fromDescription("INT", database))
            .addColumn("EXECTYPE", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
            .addColumn("MD5SUM", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
            .addColumn("DESCRIPTION", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
            .addColumn("COMMENTS", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
            .addColumn("TAG", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
            .addColumn("LIQUIBASE", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
            .addColumn("CONTEXTS", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
            .addColumn("LABELS", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database))
            .addColumn("DEPLOYMENT_ID", DataTypeFactory.getInstance().fromDescription(TypeNameChar, database));

    return CustomSqlGenerator.generateSql(database, UserSessionSettings.syncDdlStart(), createTableStatement, UserSessionSettings.syncDdlStop());
}
 
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:24,代码来源:MetastoreCreateDatabaseChangeLogTableGenerator.java

示例8: generateSql

import liquibase.database.Database; //导入依赖的package包/类
@Override
public Sql[] generateSql(TagDatabaseStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    String catalogName = database.getLiquibaseCatalogName();
    String schemaName = database.getDefaultSchemaName();
    String tableName = database.getDatabaseChangeLogTableName();
    String tableNameEscaped = database.escapeObjectName(tableName, Table.class);
    String dateColumnNameEscaped = database.escapeObjectName("DATEEXECUTED", Column.class);
    String tagColumnNameEscaped = database.escapeObjectName("TAG", Column.class);
    String tempTable = UUID.randomUUID().toString().replaceAll("-", "");
    CreateTableAsSelectStatement createTableAsSelectStatement = new CreateTableAsSelectStatement(catalogName, schemaName, tableName, tempTable)
            .addColumnNames("ID", "AUTHOR", "FILENAME", "DATEEXECUTED", "ORDEREXECUTED", "EXECTYPE", "MD5SUM", "DESCRIPTION", "COMMENTS", "TAG", "LIQUIBASE", "CONTEXTS", "LABELS", "DEPLOYMENT_ID")
            .setWhereCondition(tableNameEscaped + "." + dateColumnNameEscaped + " NOT IN (SELECT MAX(" + tableNameEscaped + "." + dateColumnNameEscaped + ") " +
                    "FROM " + tableNameEscaped + ")");
    InsertAsSelectStatement insertAsSelectStatement = new InsertAsSelectStatement(catalogName, schemaName, tableName, tempTable)
            .addColumnNames("ID", "AUTHOR", "FILENAME", "DATEEXECUTED", "ORDEREXECUTED", "EXECTYPE", "MD5SUM", "DESCRIPTION", "COMMENTS", "'" + statement.getTag() + "'", "LIQUIBASE", "CONTEXTS", "LABELS", "DEPLOYMENT_ID")
            .setWhereCondition(tableNameEscaped + "." + dateColumnNameEscaped + " IN (SELECT MAX(" + tableNameEscaped + "." + dateColumnNameEscaped + ") FROM " + tableNameEscaped + ") AND ("
                    + tableNameEscaped + "." + tagColumnNameEscaped + " IS NULL OR " + tableNameEscaped + "." + tagColumnNameEscaped + " != ?)").addWhereParameters(statement.getTag());

    return CustomSqlGenerator.generateSql(database,
            createTableAsSelectStatement,
            insertAsSelectStatement,
            new DropTableStatement(catalogName, schemaName, tableName, false),
            new RenameTableStatement(catalogName, schemaName, tempTable, tableName));
}
 
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:25,代码来源:HiveTagDatabaseGenerator.java

示例9: tag

import liquibase.database.Database; //导入依赖的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

示例10: validateDatabaseState

import liquibase.database.Database; //导入依赖的package包/类
/**
 * Validates that the database is in a good state.
 *
 * @param database The database.
 * @param fileName The change log file name.
 * @param resourceAccessor The change log file loader.
 */
private void validateDatabaseState(final Database database) throws LiquibaseException {
    final Liquibase liquibase = getLiquibase(database);
    final Contexts contexts = new Contexts(); // all contexts
    final LabelExpression labels = new LabelExpression(); // no filters
    final List<ChangeSet> unrunChangeSets = liquibase.listUnrunChangeSets(contexts, labels);
    if (!unrunChangeSets.isEmpty()) {
        throw new IllegalStateException("Unrun change sets!  Please migrate the database first");
    }
}
 
开发者ID:minijax,项目名称:minijax,代码行数:17,代码来源:LiquibaseHelper.java

示例11: generateSql

import liquibase.database.Database; //导入依赖的package包/类
public static Sql[] generateSql(Database database, SqlStatement... statements) {
    List<Sql> sqls = new ArrayList<Sql>();
    SqlGeneratorFactory generatorFactory = SqlGeneratorFactory.getInstance();
    for (SqlStatement statement : statements) {
        sqls.addAll(Arrays.asList(generatorFactory.generateSql(statement, database)));
    }
    return sqls.toArray(new Sql[sqls.size()]);
}
 
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:9,代码来源:CustomSqlGenerator.java

示例12: quietRollBack

import liquibase.database.Database; //导入依赖的package包/类
/**
 * Allow rollback a set of transactions without the need of inner try catch
 * 
 * @param database
 * @param log
 */
private static void quietRollBack(Database database, Logger log)
{
	try
	{
		database.rollback();
	}
	catch (DatabaseException e)
	{
		log.error("Rollback error",e);
	}
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:18,代码来源:SQLStatementHelper.java

示例13: generateSql

import liquibase.database.Database; //导入依赖的package包/类
@Override
public Sql[] generateSql(InvalidateMetadataStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    String catalogName = statement.getCatalogName();
    String schemaName = statement.getSchemaName();
    String tableName = statement.getTableName();
    String sql = "INVALIDATE METADATA " + database.escapeTableName(catalogName, schemaName, tableName);
    return new Sql[]{new UnparsedSql(sql, fetchAffectedTable(statement))};
}
 
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:9,代码来源:ImpalaInvalidateMetadataGenerator.java

示例14: closeQuietly

import liquibase.database.Database; //导入依赖的package包/类
static void closeQuietly(final Database database) {
    if (database != null) {
        try {
            database.close();
        } catch (final Exception ex) {
            LOG.warn("Error closing database: {}", ex.getMessage(), ex);
        }
    }
}
 
开发者ID:minijax,项目名称:minijax,代码行数:10,代码来源:LiquibaseHelper.java

示例15: generateSql

import liquibase.database.Database; //导入依赖的package包/类
@Override
public Sql[] generateSql(CreateDatabaseChangeLogLockTableStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    CreateTableStatement createTableStatement = new CreateTableStatement(database.getLiquibaseCatalogName(), database.getLiquibaseSchemaName(), database.getDatabaseChangeLogLockTableName())
            .addColumn("ID", DataTypeFactory.getInstance().fromDescription("INT", database))
            .addColumn("LOCKED", DataTypeFactory.getInstance().fromDescription("BOOLEAN", database))
            .addColumn("LOCKGRANTED", DataTypeFactory.getInstance().fromDescription("TIMESTAMP", database))
            .addColumn("LOCKEDBY", DataTypeFactory.getInstance().fromDescription("STRING", database));

    return CustomSqlGenerator.generateSql(database, UserSessionSettings.syncDdlStart(), createTableStatement, UserSessionSettings.syncDdlStop());
}
 
开发者ID:eselyavka,项目名称:liquibase-impala,代码行数:11,代码来源:MetastoreCreateDatabaseChangeLogLockTableGenerator.java


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