本文整理汇总了Java中liquibase.exception.UnexpectedLiquibaseException类的典型用法代码示例。如果您正苦于以下问题:Java UnexpectedLiquibaseException类的具体用法?Java UnexpectedLiquibaseException怎么用?Java UnexpectedLiquibaseException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnexpectedLiquibaseException类属于liquibase.exception包,在下文中一共展示了UnexpectedLiquibaseException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateSql
import liquibase.exception.UnexpectedLiquibaseException; //导入依赖的package包/类
public Sql[] generateSql(GetViewDefinitionStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
try {
String sql = "select view_definition from information_schema.views where upper(table_name)='" + statement.getViewName().toUpperCase() + "'";
if (database.convertRequestedSchemaToCatalog(statement.getSchemaName()) != null) {
sql += " and table_schema='" + database.convertRequestedSchemaToSchema(statement.getSchemaName()) + "'";
} else if (database.convertRequestedSchemaToCatalog(statement.getSchemaName()) != null) {
sql += " and table_catalog='" + database.convertRequestedSchemaToCatalog(statement.getSchemaName()) + "'";
}
return new Sql[] {
new UnparsedSql(sql)
};
} catch (DatabaseException e) {
throw new UnexpectedLiquibaseException(e);
}
}
示例2: generateSql
import liquibase.exception.UnexpectedLiquibaseException; //导入依赖的package包/类
public Sql[] generateSql(FindForeignKeyConstraintsStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
StringBuilder sb = new StringBuilder();
sb.append("SELECT ");
sb.append("RC.TABLE_NAME as ").append(FindForeignKeyConstraintsStatement.RESULT_COLUMN_BASE_TABLE_NAME).append(", ");
sb.append("KCU.COLUMN_NAME as ").append(FindForeignKeyConstraintsStatement.RESULT_COLUMN_BASE_TABLE_COLUMN_NAME).append(", ");
sb.append("RC.REFERENCED_TABLE_NAME ").append(FindForeignKeyConstraintsStatement.RESULT_COLUMN_FOREIGN_TABLE_NAME).append(", ");
sb.append("KCU.REFERENCED_COLUMN_NAME as ").append(FindForeignKeyConstraintsStatement.RESULT_COLUMN_FOREIGN_COLUMN_NAME).append(", ");
sb.append("RC.CONSTRAINT_NAME as ").append(FindForeignKeyConstraintsStatement.RESULT_COLUMN_CONSTRAINT_NAME).append(" ");
sb.append("FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS RC,");
sb.append(" INFORMATION_SCHEMA.KEY_COLUMN_USAGE KCU ");
sb.append("WHERE RC.TABLE_NAME = KCU.TABLE_NAME ");
sb.append("AND RC.CONSTRAINT_SCHEMA = KCU.CONSTRAINT_SCHEMA ");
sb.append("AND RC.CONSTRAINT_NAME = KCU.CONSTRAINT_NAME ");
sb.append("AND RC.TABLE_NAME = '").append(statement.getBaseTableName()).append("' ");
try {
sb.append("AND RC.CONSTRAINT_SCHEMA = '").append(database.convertRequestedSchemaToSchema(null)).append("'");
} catch (DatabaseException e) {
throw new UnexpectedLiquibaseException(e);
}
return new Sql[]{
new UnparsedSql(sb.toString())
};
}
示例3: addForeignKeyStatements
import liquibase.exception.UnexpectedLiquibaseException; //导入依赖的package包/类
protected void addForeignKeyStatements(AddColumnStatement statement, Database database, List<Sql> returnSql) {
for (ColumnConstraint constraint : statement.getConstraints()) {
if (constraint instanceof ForeignKeyConstraint) {
ForeignKeyConstraint fkConstraint = (ForeignKeyConstraint) constraint;
Matcher referencesMatcher = Pattern.compile("([\\w\\._]+)\\(([\\w_]+)\\)").matcher(fkConstraint.getReferences());
if (!referencesMatcher.matches()) {
throw new UnexpectedLiquibaseException("Don't know how to find table and column names from " + fkConstraint.getReferences());
}
String refSchemaName = null;
String refTableName = referencesMatcher.group(1);
if (refTableName.indexOf(".") > 0) {
refSchemaName = refTableName.split("\\.")[0];
refTableName = refTableName.split("\\.")[1];
}
String refColName = referencesMatcher.group(2);
AddForeignKeyConstraintStatement addForeignKeyConstraintStatement = new AddForeignKeyConstraintStatement(fkConstraint.getForeignKeyName(), statement.getSchemaName(), statement.getTableName(), statement.getColumnName(), refSchemaName, refTableName, refColName);
returnSql.addAll(Arrays.asList(SqlGeneratorFactory.getInstance().generateSql(addForeignKeyConstraintStatement, database)));
}
}
}
示例4: generateSql
import liquibase.exception.UnexpectedLiquibaseException; //导入依赖的package包/类
public Sql[] generateSql(SelectSequencesStatement statement,
Database database, SqlGeneratorChain sqlGeneratorChain)
{
try {
String schemaName = database.convertRequestedSchemaToSchema(
statement.getSchemaName());
return new Sql[] {
new UnparsedSql(
"SELECT " +
" seq.SEQUENCENAME AS SEQUENCE_NAME " +
"FROM " +
" SYS.SYSSEQUENCES seq, " +
" SYS.SYSSCHEMAS sch " +
"WHERE " +
" sch.SCHEMANAME = '" + schemaName + "' AND " +
" sch.SCHEMAID = seq.SCHEMAID")
};
} catch (DatabaseException e) {
throw new UnexpectedLiquibaseException(e);
}
}
示例5: generateSql
import liquibase.exception.UnexpectedLiquibaseException; //导入依赖的package包/类
public Sql[] generateSql(SelectFromDatabaseChangeLogStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
String sql = "SELECT " + StringUtils.join(statement.getColumnsToSelect(), ",").toUpperCase() + " FROM " +
database.escapeTableName(database.getLiquibaseSchemaName(), database.getDatabaseChangeLogTableName());
SelectFromDatabaseChangeLogStatement.WhereClause whereClause = statement.getWhereClause();
if (whereClause != null) {
if (whereClause instanceof SelectFromDatabaseChangeLogStatement.ByTag) {
sql += " WHERE TAG='" + ((SelectFromDatabaseChangeLogStatement.ByTag) whereClause).getTagName() + "'";
} else if (whereClause instanceof SelectFromDatabaseChangeLogStatement.ByNotNullCheckSum) {
sql += " WHERE MD5SUM IS NOT NULL";
} else {
throw new UnexpectedLiquibaseException("Unknown where clause type: " + whereClause.getClass().getName());
}
}
if (statement.getOrderByColumns() != null && statement.getOrderByColumns().length > 0) {
sql += " ORDER BY "+StringUtils.join(statement.getOrderByColumns(), ", ").toUpperCase();
}
return new Sql[]{
new UnparsedSql(sql)
};
}
示例6: generateSql
import liquibase.exception.UnexpectedLiquibaseException; //导入依赖的package包/类
public Sql[] generateSql(LockDatabaseChangeLogStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
String liquibaseSchema = null;
liquibaseSchema = database.getLiquibaseSchemaName();
InetAddress localHost;
try {
localHost = NetUtil.getLocalHost();
} catch (Exception e) {
throw new UnexpectedLiquibaseException(e);
}
UpdateStatement updateStatement = new UpdateStatement(liquibaseSchema, database.getDatabaseChangeLogLockTableName());
updateStatement.addNewColumnValue("LOCKED", true);
updateStatement.addNewColumnValue("LOCKGRANTED", new Timestamp(new java.util.Date().getTime()));
updateStatement.addNewColumnValue("LOCKEDBY", localHost.getHostName() + " (" + localHost.getHostAddress() + ")");
updateStatement.setWhereClause(database.escapeColumnName(liquibaseSchema, database.getDatabaseChangeLogTableName(), "ID") + " = 1 AND " + database.escapeColumnName(liquibaseSchema, database.getDatabaseChangeLogTableName(), "LOCKED") + " = "+ TypeConverterFactory.getInstance().findTypeConverter(database).getBooleanType().getFalseBooleanValue());
return SqlGeneratorFactory.getInstance().generateSql(updateStatement, database);
}
示例7: generateSql
import liquibase.exception.UnexpectedLiquibaseException; //导入依赖的package包/类
public Sql[] generateSql(SelectSequencesStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
try {
String schema = statement.getSchemaName();
return new Sql[] {
new UnparsedSql("SELECT relname AS SEQUENCE_NAME FROM pg_class, pg_namespace " +
"WHERE relkind='S' " +
"AND pg_class.relnamespace = pg_namespace.oid " +
"AND nspname = '" + database.convertRequestedSchemaToSchema(schema) + "' " +
"AND 'nextval(''" + (schema == null ? "" : schema + ".") + "'||relname||'''::regclass)' not in (select adsrc from pg_attrdef where adsrc is not null) " +
"AND 'nextval(''" + (schema == null ? "" : schema + ".") + "\"'||relname||'\"''::regclass)' not in (select adsrc from pg_attrdef where adsrc is not null) " +
"AND 'nextval('''||relname||'''::regclass)' not in (select adsrc from pg_attrdef where adsrc is not null)")
};
} catch (DatabaseException e) {
throw new UnexpectedLiquibaseException(e);
}
}
示例8: ChangeLogParserFactory
import liquibase.exception.UnexpectedLiquibaseException; //导入依赖的package包/类
private ChangeLogParserFactory() {
Class<? extends ChangeLogParser>[] classes;
changelogParserComparator = new Comparator<ChangeLogParser>() {
public int compare(ChangeLogParser o1, ChangeLogParser o2) {
return Integer.valueOf(o2.getPriority()).compareTo(o1.getPriority());
}
};
parsers = new ArrayList<ChangeLogParser>();
try {
classes = ServiceLocator.getInstance().findClasses(ChangeLogParser.class);
for (Class<? extends ChangeLogParser> clazz : classes) {
register((ChangeLogParser) clazz.getConstructor().newInstance());
}
} catch (Exception e) {
throw new UnexpectedLiquibaseException(e);
}
}
示例9: hasTable
import liquibase.exception.UnexpectedLiquibaseException; //导入依赖的package包/类
public boolean hasTable(String schemaName, String tableName, Database database) {
try {
ResultSet rs = getMetaData(database).getTables(database.convertRequestedSchemaToCatalog(schemaName),
database.convertRequestedSchemaToSchema(schemaName),
convertTableNameToDatabaseTableName(tableName), new String[] { "TABLE" });
try {
return rs.next();
} finally {
try {
rs.close();
} catch (SQLException ignore) {
}
}
} catch (Exception e) {
throw new UnexpectedLiquibaseException(e);
}
}
示例10: hasView
import liquibase.exception.UnexpectedLiquibaseException; //导入依赖的package包/类
public boolean hasView(String schemaName, String viewName, Database database) {
try {
ResultSet rs = getMetaData(database).getTables(database.convertRequestedSchemaToCatalog(schemaName),
database.convertRequestedSchemaToSchema(schemaName), convertTableNameToDatabaseTableName(viewName),
new String[] { "VIEW" });
try {
return rs.next();
} finally {
try {
rs.close();
} catch (SQLException ignore) {
}
}
} catch (Exception e) {
throw new UnexpectedLiquibaseException(e);
}
}
示例11: computeMD5
import liquibase.exception.UnexpectedLiquibaseException; //导入依赖的package包/类
public static String computeMD5(String input) {
if (input == null) {
return null;
}
MessageDigest digest;
try {
digest = MessageDigest.getInstance("MD5");
digest.update(input.getBytes("UTF-8"));
} catch (Exception e) {
throw new UnexpectedLiquibaseException(e);
}
byte[] digestBytes = digest.digest();
String returnString = new String(encodeHex(digestBytes));
LogFactory.getLogger().debug("Computed checksum for "+input+" as "+returnString);
return returnString;
}
示例12: setOnDelete
import liquibase.exception.UnexpectedLiquibaseException; //导入依赖的package包/类
public void setOnDelete(ForeignKeyConstraintType rule) {
if (rule == null) {
//nothing
} else if (rule == ForeignKeyConstraintType.importedKeyCascade) {
setOnDelete("CASCADE");
} else if (rule == ForeignKeyConstraintType.importedKeySetNull) {
setOnDelete("SET NULL");
} else if (rule == ForeignKeyConstraintType.importedKeySetDefault) {
setOnDelete("SET DEFAULT");
} else if (rule == ForeignKeyConstraintType.importedKeyRestrict) {
setOnDelete("RESTRICT");
} else if (rule == ForeignKeyConstraintType.importedKeyNoAction){
setOnDelete("NO ACTION");
} else {
throw new UnexpectedLiquibaseException("Unknown onDelete action: "+rule);
}
}
示例13: setOnUpdate
import liquibase.exception.UnexpectedLiquibaseException; //导入依赖的package包/类
public void setOnUpdate(ForeignKeyConstraintType rule) {
if (rule == null) {
//nothing
} else if (rule == ForeignKeyConstraintType.importedKeyCascade) {
setOnUpdate("CASCADE");
} else if (rule == ForeignKeyConstraintType.importedKeySetNull) {
setOnUpdate("SET NULL");
} else if (rule == ForeignKeyConstraintType.importedKeySetDefault) {
setOnUpdate("SET DEFAULT");
} else if (rule == ForeignKeyConstraintType.importedKeyRestrict) {
setOnUpdate("RESTRICT");
} else if (rule == ForeignKeyConstraintType.importedKeyNoAction) {
setOnUpdate("NO ACTION");
} else {
throw new UnexpectedLiquibaseException("Unknown onUpdate action: "+onUpdate);
}
}
示例14: generateSqlIfExists
import liquibase.exception.UnexpectedLiquibaseException; //导入依赖的package包/类
/**
* Generates the SQL statement to drop the spatial index if it exists.
*
* @param statement
* the drop spatial index statement.
* @param database
* the database.
* @return the drop spatial index statement, if the index exists.
*/
public Sql[] generateSqlIfExists(final DropSpatialIndexStatement statement,
final Database database) {
final String catalogName = statement.getTableCatalogName();
final String schemaName = statement.getTableSchemaName();
final String tableName = statement.getTableName();
final SpatialIndexExistsPrecondition precondition = new SpatialIndexExistsPrecondition();
precondition.setCatalogName(catalogName);
precondition.setSchemaName(schemaName);
precondition.setTableName(tableName);
final DatabaseObject example = precondition.getExample(database, tableName);
try {
// If a spatial index exists on the table, drop it.
if (SnapshotGeneratorFactory.getInstance().has(example, database)) {
return generateSql(statement, database, null);
}
} catch (final Exception e) {
throw new UnexpectedLiquibaseException(e);
}
return new Sql[0];
}
示例15: loadOracleSrid
import liquibase.exception.UnexpectedLiquibaseException; //导入依赖的package包/类
/**
* Queries to the database to convert the given EPSG SRID to the corresponding Oracle SRID.
*
* @param srid
* the EPSG SRID.
* @param database
* the database instance.
* @return the corresponding Oracle SRID.
*/
public static String loadOracleSrid(final String srid, final Database database) {
final String oracleSrid;
final JdbcConnection jdbcConnection = (JdbcConnection) database.getConnection();
final Connection connection = jdbcConnection.getUnderlyingConnection();
Statement statement = null;
try {
statement = connection.createStatement();
final ResultSet resultSet = statement.executeQuery("SELECT " + EPSG_TO_ORACLE_FUNCTION
+ "(" + srid + ") FROM dual");
resultSet.next();
oracleSrid = resultSet.getString(1);
} catch (final SQLException e) {
throw new UnexpectedLiquibaseException("Failed to find the Oracle SRID for EPSG:" + srid,
e);
} finally {
try {
statement.close();
} catch (final SQLException ignore) {
}
}
return oracleSrid;
}