本文整理汇总了Java中liquibase.exception.UnexpectedLiquibaseException类的典型用法代码示例。如果您正苦于以下问题:Java UnexpectedLiquibaseException类的具体用法?Java UnexpectedLiquibaseException怎么用?Java UnexpectedLiquibaseException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnexpectedLiquibaseException类属于liquibase.exception包,在下文中一共展示了UnexpectedLiquibaseException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:17,代码来源:GetViewDefinitionGenerator.java
示例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())
};
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:25,代码来源:FindForeignKeyConstraintsGeneratorMySQL.java
示例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)));
}
}
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:22,代码来源:AddColumnGenerator.java
示例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);
}
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:22,代码来源:SelectSequencesGeneratorDerby.java
示例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)
};
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:24,代码来源:SelectFromDatabaseChangeLogGenerator.java
示例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);
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:21,代码来源:LockDatabaseChangeLogGenerator.java
示例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);
}
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:18,代码来源:SelectSequencesGeneratorPostgres.java
示例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);
}
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:21,代码来源:ChangeLogParserFactory.java
示例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);
}
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:18,代码来源:JdbcDatabaseSnapshotGenerator.java
示例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);
}
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:18,代码来源:JdbcDatabaseSnapshotGenerator.java
示例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;
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:19,代码来源:MD5Util.java
示例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);
}
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:18,代码来源:AddForeignKeyConstraintChange.java
示例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);
}
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:18,代码来源:AddForeignKeyConstraintChange.java
示例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];
}
开发者ID:lonnyj,项目名称:liquibase-spatial,代码行数:30,代码来源:DropSpatialIndexGeneratorGeoDB.java
示例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;
}
开发者ID:lonnyj,项目名称:liquibase-spatial,代码行数:32,代码来源:OracleSpatialUtils.java
示例16: objectToSql
import liquibase.exception.UnexpectedLiquibaseException; //导入依赖的package包/类
/**
* @see liquibase.datatype.LiquibaseDataType#objectToSql(java.lang.Object,
* liquibase.database.Database)
*/
@Override
public String objectToSql(final Object value, final Database database) {
final String returnValue;
if (value instanceof Geometry) {
// TODO: Tailor the output for the database.
returnValue = ((Geometry) value).toText();
} else if (value instanceof String) {
returnValue = value.toString();
} else if (value instanceof DatabaseFunction) {
returnValue = value.toString();
} else if (value == null || value.toString().equalsIgnoreCase("null")) {
returnValue = null;
} else {
throw new UnexpectedLiquibaseException("Cannot convert type " + value.getClass()
+ " to a Geometry value");
}
return returnValue;
}
开发者ID:lonnyj,项目名称:liquibase-spatial,代码行数:23,代码来源:GeometryType.java
示例17: sqlToObject
import liquibase.exception.UnexpectedLiquibaseException; //导入依赖的package包/类
/**
* @see liquibase.datatype.LiquibaseDataType#sqlToObject(java.lang.String,
* liquibase.database.Database)
*/
@Override
public Object sqlToObject(final String value, final Database database) {
final Geometry returnValue;
if (value == null || value.equalsIgnoreCase("null")) {
returnValue = null;
} else {
final WKTReader reader = new WKTReader();
try {
// TODO: Check for SRID.
returnValue = reader.read(value);
} catch (final ParseException e) {
throw new UnexpectedLiquibaseException("Cannot parse " + value + " to a Geometry", e);
}
}
return returnValue;
}
开发者ID:lonnyj,项目名称:liquibase-spatial,代码行数:21,代码来源:GeometryType.java
示例18: getSerializableFieldValue
import liquibase.exception.UnexpectedLiquibaseException; //导入依赖的package包/类
/**
* @see liquibase.serializer.LiquibaseSerializable#getSerializableFieldValue(java.lang.String)
*/
@Override
public Object getSerializableFieldValue(final String field) {
final Object value;
if ("catalogName".equals(field)) {
value = getCatalogName();
} else if ("schemaName".equals(field)) {
value = getSchemaName();
} else if ("tableName".equals(field)) {
value = getTableName();
} else if ("columnNames".equals(field)) {
value = getColumnNames();
} else if ("indexName".equals(field)) {
value = getIndexName();
} else {
throw new UnexpectedLiquibaseException("Unexpected field request on "
+ getSerializedObjectName() + ": " + field);
}
return value;
}
开发者ID:lonnyj,项目名称:liquibase-spatial,代码行数:23,代码来源:SpatialIndexExistsPrecondition.java
示例19: geometryColumnsExists
import liquibase.exception.UnexpectedLiquibaseException; //导入依赖的package包/类
/**
* Indicates if the <code>GEOMETRY_COLUMNS</code> table or view exists.
*
* @param database
* the database to check.
* @return <code>true</code> if the table or view exists.
*/
public static boolean geometryColumnsExists(final Database database) {
String geometryColumnsName = database.correctObjectName(
"geometry_columns", Table.class);
DatabaseObject example = null;
if (database instanceof DerbyDatabase || database instanceof H2Database) {
final Table tableExample = new Table();
tableExample.setName(geometryColumnsName);
tableExample.setSchema(database.getDefaultCatalogName(),
database.getDefaultSchemaName());
example = tableExample;
} else if (database instanceof PostgresDatabase) {
final View viewExample = new View();
viewExample.setName(geometryColumnsName);
viewExample.setSchema(database.getDefaultCatalogName(), "public");
example = viewExample;
}
try {
return example != null
&& SnapshotGeneratorFactory.getInstance().has(example, database);
} catch (final LiquibaseException e) {
throw new UnexpectedLiquibaseException(
"Failed to determine if the geometry_columns table or view exists",
e);
}
}
开发者ID:lonnyj,项目名称:liquibase-spatial,代码行数:33,代码来源:GeometryColumnsUtils.java
示例20: getColumnDataDefinition
import liquibase.exception.UnexpectedLiquibaseException; //导入依赖的package包/类
public static String getColumnDataDefinition(Database database,
String catalogName, String schemaName, String tableName, String columnName) {
assertNotNull(tableName, "No table name specified");
assertNotNull(columnName, "No column name specified");
JdbcConnection conn = (JdbcConnection) database.getConnection();
assertNotNull(conn, "Could not retrieve a connection");
ColumnMetaData columnData;
try {
columnData = DatabaseMetaDataAccessor.getColumnMetaData(conn, catalogName, schemaName, tableName, columnName);
} catch (DatabaseException e) {
throw new UnexpectedLiquibaseException(e);
}
assertNotNull(columnData, "Could not determine data type for column = '" + columnName + "' table = '" + tableName +
"' schema = '" + schemaName + "' catalog = '" + catalogName + '\'');
String columnDefinition;
if (columnData.requiresSizeForDefinition()) {
columnDefinition = columnData.getTypeName() + '(' + columnData.getColumnSize() + ')';
} else {
columnDefinition = columnData.getTypeName();
}
return columnDefinition;
}
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:24,代码来源:SqlGeneratorHelperHanaDB.java
注:本文中的liquibase.exception.UnexpectedLiquibaseException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论