flowable兼容Gaussdb数据库

2024-02-10 02:50

本文主要是介绍flowable兼容Gaussdb数据库,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

步骤一、

在项目中创建org.flowable.common.engine.impl.AbstractEngineConfiguration文件(这边路径必须一致,打包时会覆盖源文件,将源码全部复制过来),修改其中getDefaultDatabaseTypeMappings方法,将Gauss数据库标识为mysql(尝试过其他的报错就不试了,就用mysql)

//在AbstractEngineConfiguration类中
//添加静态属性
public static final String DATABASE_TYPE_GAUSS = "mysql";//加入Gauss支持
//在以下方法中添加下面这行代码
public static Properties getDefaultDatabaseTypeMappings() {................databaseTypeMappings.setProperty("Zenith", DATABASE_TYPE_GAUSS);//加入Gauss支持  待添加return databaseTypeMappings;
}

 步骤二、

修改liquibase-core-4.3.5.jar中源码

1.创建GaussDatabase,继承AbstractJdbcDatabase,具体的类实现从OracleDatabase类中复制,然后进行如下修改

删除setConnection方法;

修改PRODUCT_NAME常量值为“Zenith”;

修改getDefaultPort方法,返回1888;//具体端口随着上线更改

修改getShortName方法,返回 zenith

修改getDefaultDriver方法,返回Gauss的Driver。//驱动

具体操作:1.在项目中新建如下包名,创建自己的GaussDatabase类,复制如下代码,根据具体情况作相应修改

 

package liquibase.database.core;import java.lang.reflect.Method;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import liquibase.CatalogAndSchema;
import liquibase.Scope;
import liquibase.database.AbstractJdbcDatabase;
import liquibase.database.DatabaseConnection;
import liquibase.database.OfflineConnection;
import liquibase.database.jvm.JdbcConnection;
import liquibase.exception.DatabaseException;
import liquibase.exception.UnexpectedLiquibaseException;
import liquibase.exception.ValidationErrors;
import liquibase.executor.ExecutorService;
import liquibase.statement.DatabaseFunction;
import liquibase.statement.SequenceCurrentValueFunction;
import liquibase.statement.SequenceNextValueFunction;
import liquibase.statement.UniqueConstraint;
import liquibase.statement.core.RawCallStatement;
import liquibase.statement.core.RawSqlStatement;
import liquibase.structure.DatabaseObject;
import liquibase.structure.core.Catalog;
import liquibase.structure.core.Index;
import liquibase.structure.core.PrimaryKey;
import liquibase.structure.core.Schema;
import liquibase.util.JdbcUtils;
import liquibase.util.StringUtil;/*** @Description:* @Author: gx* @Date: 2023/09/11/ 13:42*/
public class GaussDatabase extends AbstractJdbcDatabase {private static final String PRODUCT_NAME = "Zenith";@Overrideprotected String getDefaultDatabaseProductName() {return PRODUCT_NAME;}/*** Is this AbstractDatabase subclass the correct one to use for the given connection.** @param conn*/@Overridepublic boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws DatabaseException {return PRODUCT_NAME.equalsIgnoreCase(conn.getDatabaseProductName());}/*** If this database understands the given url, return the default driver class name.  Otherwise return null.** @param url*/@Overridepublic String getDefaultDriver(String url) {if(url.startsWith("jdbc:zenith")) {return "com.huawei.gauss.jdbc.ZenithDriver";}return null;}/*** Returns an all-lower-case short name of the product.  Used for end-user selecting of database type* such as the DBMS precondition.*/@Overridepublic String getShortName() {return "zenith";}@Overridepublic Integer getDefaultPort() {return 1888;}/*** Returns whether this database support initially deferrable columns.*/@Overridepublic boolean supportsInitiallyDeferrableColumns() {return true;}@Overridepublic boolean supportsTablespaces() {return true;}@Overridepublic int getPriority() {return PRIORITY_DEFAULT;}private static final Pattern PROXY_USER = Pattern.compile(".*(?:thin|oci)\\:(.+)/@.*");protected final int SHORT_IDENTIFIERS_LENGTH = 30;protected final int LONG_IDENTIFIERS_LEGNTH = 128;public static final int ORACLE_12C_MAJOR_VERSION = 12;private Set<String> reservedWords = new HashSet<>();private Set<String> userDefinedTypes;private Map<String, String> savedSessionNlsSettings;private Boolean canAccessDbaRecycleBin;private Integer databaseMajorVersion;private Integer databaseMinorVersion;/*** Default constructor for an object that represents the Oracle Database DBMS.*/public GaussDatabase() {super.unquotedObjectsAreUppercased = true;//noinspection HardCodedStringLiteralsuper.setCurrentDateTimeFunction("SYSTIMESTAMP");// Setting list of Oracle's native functions//noinspection HardCodedStringLiteraldateFunctions.add(new DatabaseFunction("SYSDATE"));//noinspection HardCodedStringLiteraldateFunctions.add(new DatabaseFunction("SYSTIMESTAMP"));//noinspection HardCodedStringLiteraldateFunctions.add(new DatabaseFunction("CURRENT_TIMESTAMP"));//noinspection HardCodedStringLiteralsuper.sequenceNextValueFunction = "%s.nextval";//noinspection HardCodedStringLiteralsuper.sequenceCurrentValueFunction = "%s.currval";}private void tryProxySession(final String url, final Connection con) {Matcher m = PROXY_USER.matcher(url);if (m.matches()) {Properties props = new Properties();props.put("PROXY_USER_NAME", m.group(1));try {Method method = con.getClass().getMethod("openProxySession", int.class, Properties.class);method.setAccessible(true);method.invoke(con, 1, props);} catch (Exception e) {Scope.getCurrentScope().getLog(getClass()).info("Could not open proxy session on OracleDatabase: " + e.getCause().getMessage());}}}@Overridepublic int getDatabaseMajorVersion() throws DatabaseException {if (databaseMajorVersion == null) {return super.getDatabaseMajorVersion();} else {return databaseMajorVersion;}}@Overridepublic int getDatabaseMinorVersion() throws DatabaseException {if (databaseMinorVersion == null) {return super.getDatabaseMinorVersion();} else {return databaseMinorVersion;}}@Overridepublic String getJdbcCatalogName(CatalogAndSchema schema) {return null;}@Overridepublic String getJdbcSchemaName(CatalogAndSchema schema) {return correctObjectName((schema.getCatalogName() == null) ? schema.getSchemaName() : schema.getCatalogName(), Schema.class);}@Overrideprotected String getAutoIncrementClause(final String generationType, final Boolean defaultOnNull) {if (StringUtil.isEmpty(generationType)) {return super.getAutoIncrementClause();}String autoIncrementClause = "GENERATED %s AS IDENTITY"; // %s -- [ ALWAYS | BY DEFAULT [ ON NULL ] ]String generationStrategy = generationType;if (Boolean.TRUE.equals(defaultOnNull) && generationType.toUpperCase().equals("BY DEFAULT")) {generationStrategy += " ON NULL";}return String.format(autoIncrementClause, generationStrategy);}@Overridepublic String generatePrimaryKeyName(String tableName) {if (tableName.length() > 27) {//noinspection HardCodedStringLiteralreturn "PK_" + tableName.toUpperCase(Locale.US).substring(0, 27);} else {//noinspection HardCodedStringLiteralreturn "PK_" + tableName.toUpperCase(Locale.US);}}@Overridepublic boolean isReservedWord(String objectName) {return reservedWords.contains(objectName.toUpperCase());}@Overridepublic boolean supportsSequences() {return true;}/*** Oracle supports catalogs in liquibase terms** @return false*/@Overridepublic boolean supportsSchemas() {return false;}@Overrideprotected String getConnectionCatalogName() throws DatabaseException {if (getConnection() instanceof OfflineConnection) {return getConnection().getCatalog();}try {//noinspection HardCodedStringLiteralreturn Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", this).queryForObject(new RawCallStatement("select sys_context( 'userenv', 'current_schema' ) from dual"), String.class);} catch (Exception e) {//noinspection HardCodedStringLiteralScope.getCurrentScope().getLog(getClass()).info("Error getting default schema", e);}return null;}@Overridepublic String getDefaultCatalogName() {//NOPMDreturn (super.getDefaultCatalogName() == null) ? null : super.getDefaultCatalogName().toUpperCase(Locale.US);}/*** <p>Returns an Oracle date literal with the same value as a string formatted using ISO 8601.</p>** <p>Convert an ISO8601 date string to one of the following results:* to_date('1995-05-23', 'YYYY-MM-DD')* to_date('1995-05-23 09:23:59', 'YYYY-MM-DD HH24:MI:SS')</p>* <p>* Implementation restriction:<br>* Currently, only the following subsets of ISO8601 are supported:<br>* <ul>* <li>YYYY-MM-DD</li>* <li>YYYY-MM-DDThh:mm:ss</li>* </ul>*/@Overridepublic String getDateLiteral(String isoDate) {String normalLiteral = super.getDateLiteral(isoDate);if (isDateOnly(isoDate)) {return "TO_DATE(" + normalLiteral + ", 'YYYY-MM-DD')";} else if (isTimeOnly(isoDate)) {return "TO_DATE(" + normalLiteral + ", 'HH24:MI:SS')";} else if (isTimestamp(isoDate)) {return "TO_TIMESTAMP(" + normalLiteral + ", 'YYYY-MM-DD HH24:MI:SS.FF')";} else if (isDateTime(isoDate)) {int seppos = normalLiteral.lastIndexOf('.');if (seppos != -1) {normalLiteral = normalLiteral.substring(0, seppos) + "'";}return "TO_DATE(" + normalLiteral + ", 'YYYY-MM-DD HH24:MI:SS')";}return "UNSUPPORTED:" + isoDate;}@Overridepublic boolean isSystemObject(DatabaseObject example) {if (example == null) {return false;}if (this.isLiquibaseObject(example)) {return false;}if (example instanceof Schema) {//noinspection HardCodedStringLiteral,HardCodedStringLiteral,HardCodedStringLiteral,HardCodedStringLiteralif ("SYSTEM".equals(example.getName()) || "SYS".equals(example.getName()) || "CTXSYS".equals(example.getName()) || "XDB".equals(example.getName())) {return true;}//noinspection HardCodedStringLiteral,HardCodedStringLiteral,HardCodedStringLiteral,HardCodedStringLiteralif ("SYSTEM".equals(example.getSchema().getCatalogName()) || "SYS".equals(example.getSchema().getCatalogName()) || "CTXSYS".equals(example.getSchema().getCatalogName()) || "XDB".equals(example.getSchema().getCatalogName())) {return true;}} else if (isSystemObject(example.getSchema())) {return true;}if (example instanceof Catalog) {//noinspection HardCodedStringLiteral,HardCodedStringLiteral,HardCodedStringLiteral,HardCodedStringLiteralif (("SYSTEM".equals(example.getName()) || "SYS".equals(example.getName()) || "CTXSYS".equals(example.getName()) || "XDB".equals(example.getName()))) {return true;}} else if (example.getName() != null) {//noinspection HardCodedStringLiteralif (example.getName().startsWith("BIN$")) { //oracle deleted tableboolean filteredInOriginalQuery = this.canAccessDbaRecycleBin();if (!filteredInOriginalQuery) {filteredInOriginalQuery = StringUtil.trimToEmpty(example.getSchema().getName()).equalsIgnoreCase(this.getConnection().getConnectionUserName());}if (filteredInOriginalQuery) {return !((example instanceof PrimaryKey) || (example instanceof Index) || (example instanceofliquibase.statement.UniqueConstraint));} else {return true;}} else //noinspection HardCodedStringLiteralif (example.getName().startsWith("AQ$")) { //oracle AQ tablesreturn true;} else //noinspection HardCodedStringLiteralif (example.getName().startsWith("DR$")) { //oracle index tablesreturn true;} else //noinspection HardCodedStringLiteralif (example.getName().startsWith("SYS_IOT_OVER")) { //oracle system tablereturn true;} else //noinspection HardCodedStringLiteral,HardCodedStringLiteralif ((example.getName().startsWith("MDRT_") || example.getName().startsWith("MDRS_")) && example.getName().endsWith("$")) {// CORE-1768 - Oracle creates these for spatial indices and will remove them when the index is removed.return true;} else //noinspection HardCodedStringLiteralif (example.getName().startsWith("MLOG$_")) { //Created by materliaized view logs for every table that is part of a materialized view. Not available for DDL operations.return true;} else //noinspection HardCodedStringLiteralif (example.getName().startsWith("RUPD$_")) { //Created by materialized view log tables using primary keys. Not available for DDL operations.return true;} else //noinspection HardCodedStringLiteralif (example.getName().startsWith("WM$_")) { //Workspace Manager backup tables.return true;} else //noinspection HardCodedStringLiteralif ("CREATE$JAVA$LOB$TABLE".equals(example.getName())) { //This table contains the name of the Java object, the date it was loaded, and has a BLOB column to store the Java object.return true;} else //noinspection HardCodedStringLiteralif ("JAVA$CLASS$MD5$TABLE".equals(example.getName())) { //This is a hash table that tracks the loading of Java objects into a schema.return true;} else //noinspection HardCodedStringLiteralif (example.getName().startsWith("ISEQ$$_")) { //System-generated sequencereturn true;} else //noinspection HardCodedStringLiteralif (example.getName().startsWith("USLOG$")) { //for update materialized viewreturn true;} else if (example.getName().startsWith("SYS_FBA")) { //for Flashback tablesreturn true;}}return super.isSystemObject(example);}@Overridepublic boolean supportsAutoIncrement() {// Oracle supports Identity beginning with version 12cboolean isAutoIncrementSupported = false;try {if (getDatabaseMajorVersion() >= 12) {isAutoIncrementSupported = true;}// Returning true will generate create table command with 'IDENTITY' clause, example:// CREATE TABLE AutoIncTest (IDPrimaryKey NUMBER(19) GENERATED BY DEFAULT AS IDENTITY NOT NULL, TypeID NUMBER(3) NOT NULL, Description NVARCHAR2(50), CONSTRAINT PK_AutoIncTest PRIMARY KEY (IDPrimaryKey));// While returning false will continue to generate create table command without 'IDENTITY' clause, example:// CREATE TABLE AutoIncTest (IDPrimaryKey NUMBER(19) NOT NULL, TypeID NUMBER(3) NOT NULL, Description NVARCHAR2(50), CONSTRAINT PK_AutoIncTest PRIMARY KEY (IDPrimaryKey));} catch (DatabaseException ex) {isAutoIncrementSupported = false;}return isAutoIncrementSupported;}@Overridepublic boolean supportsRestrictForeignKeys() {return false;}@Overridepublic int getDataTypeMaxParameters(String dataTypeName) {//noinspection HardCodedStringLiteralif ("BINARY_FLOAT".equals(dataTypeName.toUpperCase())) {return 0;}//noinspection HardCodedStringLiteralif ("BINARY_DOUBLE".equals(dataTypeName.toUpperCase())) {return 0;}return super.getDataTypeMaxParameters(dataTypeName);}public String getSystemTableWhereClause(String tableNameColumn) {List<String> clauses = new ArrayList<String>(Arrays.asList("BIN$","AQ$","DR$","SYS_IOT_OVER","MLOG$_","RUPD$_","WM$_","ISEQ$$_","USLOG$","SYS_FBA"));for (int i = 0;i<clauses.size(); i++) {clauses.set(i, tableNameColumn+" NOT LIKE '"+clauses.get(i)+"%'");}return "("+ StringUtil.join(clauses, " AND ") + ")";}@Overridepublic boolean jdbcCallsCatalogsSchemas() {return true;}public Set<String> getUserDefinedTypes() {if (userDefinedTypes == null) {userDefinedTypes = new HashSet<>();if ((getConnection() != null) && !(getConnection() instanceof OfflineConnection)) {try {try {//noinspection HardCodedStringLiteraluserDefinedTypes.addAll(Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", this).queryForList(new RawSqlStatement("SELECT DISTINCT TYPE_NAME FROM ALL_TYPES"), String.class));} catch (DatabaseException e) { //fall back to USER_TYPES if the user cannot see ALL_TYPES//noinspection HardCodedStringLiteraluserDefinedTypes.addAll(Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", this).queryForList(new RawSqlStatement("SELECT TYPE_NAME FROM USER_TYPES"), String.class));}} catch (DatabaseException e) {//ignore error}}}return userDefinedTypes;}@Overridepublic String generateDatabaseFunctionValue(DatabaseFunction databaseFunction) {//noinspection HardCodedStringLiteralif ((databaseFunction != null) && "current_timestamp".equalsIgnoreCase(databaseFunction.toString())) {return databaseFunction.toString();}if ((databaseFunction instanceof SequenceNextValueFunction) || (databaseFunction instanceofSequenceCurrentValueFunction)) {String quotedSeq = super.generateDatabaseFunctionValue(databaseFunction);// replace "myschema.my_seq".nextval with "myschema"."my_seq".nextvalreturn quotedSeq.replaceFirst("\"([^\\.\"]+)\\.([^\\.\"]+)\"", "\"$1\".\"$2\"");}return super.generateDatabaseFunctionValue(databaseFunction);}@Overridepublic ValidationErrors validate() {ValidationErrors errors = super.validate();DatabaseConnection connection = getConnection();if ((connection == null) || (connection instanceof OfflineConnection)) {//noinspection HardCodedStringLiteralScope.getCurrentScope().getLog(getClass()).info("Cannot validate offline database");return errors;}if (!canAccessDbaRecycleBin()) {errors.addWarning(getDbaRecycleBinWarning());}return errors;}public String getDbaRecycleBinWarning() {return "Liquibase needs to access the DBA_RECYCLEBIN table so we can automatically handle the case where " +"constraints are deleted and restored. Since Oracle doesn't properly restore the original table names " +"referenced in the constraint, we use the information from the DBA_RECYCLEBIN to automatically correct this" +" issue.\n" +"\n" +"The user you used to connect to the database (" + getConnection().getConnectionUserName() +") needs to have \"SELECT ON SYS.DBA_RECYCLEBIN\" permissions set before we can perform this operation. " +"Please run the following SQL to set the appropriate permissions, and try running the command again.\n" +"\n" +"     GRANT SELECT ON SYS.DBA_RECYCLEBIN TO " + getConnection().getConnectionUserName() + ";";}public boolean canAccessDbaRecycleBin() {if (canAccessDbaRecycleBin == null) {DatabaseConnection connection = getConnection();if ((connection == null) || (connection instanceof OfflineConnection)) {return false;}Statement statement = null;try {statement = ((JdbcConnection) connection).createStatement();@SuppressWarnings("HardCodedStringLiteral") ResultSet resultSet = statement.executeQuery("select 1 from dba_recyclebin where 0=1");resultSet.close(); //don't need to do anything with the result set, just make sure statement ran.this.canAccessDbaRecycleBin = true;} catch (Exception e) {//noinspection HardCodedStringLiteralif ((e instanceof SQLException) && e.getMessage().startsWith("ORA-00942")) { //ORA-00942: table or view does not existthis.canAccessDbaRecycleBin = false;} else {//noinspection HardCodedStringLiteralScope.getCurrentScope().getLog(getClass()).warning("Cannot check dba_recyclebin access", e);this.canAccessDbaRecycleBin = false;}} finally {JdbcUtils.close(null, statement);}}return canAccessDbaRecycleBin;}@Overridepublic boolean supportsNotNullConstraintNames() {return true;}/*** Tests if the given String would be a valid identifier in Oracle DBMS. In Oracle, a valid identifier has* the following form (case-insensitive comparison):* 1st character: A-Z* 2..n characters: A-Z0-9$_#* The maximum length of an identifier differs by Oracle version and object type.*/public boolean isValidOracleIdentifier(String identifier, Class<? extends DatabaseObject> type) {if ((identifier == null) || (identifier.length() < 1))return false;if (!identifier.matches("^(i?)[A-Z][A-Z0-9\\$\\_\\#]*$"))return false;/** @todo It seems we currently do not have a class for tablespace identifiers, and all other classes* we do know seem to be supported as 12cR2 long identifiers, so:*/return (identifier.length() <= LONG_IDENTIFIERS_LEGNTH);}/*** Returns the maximum number of bytes (NOT: characters) for an identifier. For Oracle <=12c Release 20, this* is 30 bytes, and starting from 12cR2, up to 128 (except for tablespaces, PDB names and some other rather rare* object types).** @return the maximum length of an object identifier, in bytes*/public int getIdentifierMaximumLength() {try {if (getDatabaseMajorVersion() < ORACLE_12C_MAJOR_VERSION) {return SHORT_IDENTIFIERS_LENGTH;} else if ((getDatabaseMajorVersion() == ORACLE_12C_MAJOR_VERSION) && (getDatabaseMinorVersion() <= 1)) {return SHORT_IDENTIFIERS_LENGTH;} else {return LONG_IDENTIFIERS_LEGNTH;}} catch (DatabaseException ex) {throw new UnexpectedLiquibaseException("Cannot determine the Oracle database version number", ex);}}
}

 步骤三、

修改 liquibase.datatype.core.BooleanType类,以支持Gauss的bit类型与java的Boolean类型的转换

在toDatabaseDataType方法中添加DmDatabase的支持

在isNumericBoolean方法中添加DmDatabase类型

具体操作如下:1.在当前项目新建包名,修改代码

2.这里转换可能还是会有问题,我们暂时不做考虑,他只是影响自动创建表,我们在application.yml中添加如下配置吗,不让他自己创建表

# flowable相关表

flowable:

# true 会对数据库中所有表进行更新操作。如果表不存在,则自动创建(建议开发时使用)

database-schema-update: false

# 关闭定时任务JOB

async-executor-activate: false

package liquibase.datatype.core;import java.util.Locale;import liquibase.change.core.LoadDataChange;
import liquibase.database.Database;
import liquibase.database.core.*;
import liquibase.datatype.DataTypeInfo;
import liquibase.datatype.DatabaseDataType;
import liquibase.datatype.LiquibaseDataType;
import liquibase.exception.UnexpectedLiquibaseException;
import liquibase.statement.DatabaseFunction;
import liquibase.util.StringUtil;@DataTypeInfo(name = "boolean",aliases = {"java.sql.Types.BOOLEAN", "java.lang.Boolean", "bit", "bool"},minParameters = 0,maxParameters = 0,priority = 1)
public class BooleanType extends LiquibaseDataType {public BooleanType() {}@Overridepublic DatabaseDataType toDatabaseDataType(Database database) {String originalDefinition = StringUtil.trimToEmpty(getRawDefinition());if ((database instanceof Firebird3Database)) {return new DatabaseDataType("BOOLEAN");}if ((database instanceof AbstractDb2Database) || (database instanceof FirebirdDatabase)) {return new DatabaseDataType("SMALLINT");} else if (database instanceof MSSQLDatabase) {return new DatabaseDataType(database.escapeDataTypeName("bit"));} else if (database instanceof MySQLDatabase) {if (originalDefinition.toLowerCase(Locale.US).startsWith("bit")) {return new DatabaseDataType("BIT", getParameters());}return new DatabaseDataType("BIT", 1);} else if (database instanceof OracleDatabase) {return new DatabaseDataType("NUMBER", 1);} else if ((database instanceof SybaseASADatabase) || (database instanceof SybaseDatabase)) {return new DatabaseDataType("BIT");} else if (database instanceof DerbyDatabase) {if (((DerbyDatabase) database).supportsBooleanDataType()) {return new DatabaseDataType("BOOLEAN");} else {return new DatabaseDataType("SMALLINT");}} else if (database.getClass().isAssignableFrom(DB2Database.class)) {if (((DB2Database) database).supportsBooleanDataType()) return new DatabaseDataType("BOOLEAN");else return new DatabaseDataType("SMALLINT");} else if (database instanceof HsqlDatabase) {return new DatabaseDataType("BOOLEAN");} else if (database instanceof PostgresDatabase) {if (originalDefinition.toLowerCase(Locale.US).startsWith("bit")) {return new DatabaseDataType("BIT", getParameters());}} else if (database instanceof GaussDatabase) {return new DatabaseDataType("bit");}return super.toDatabaseDataType(database);}@Overridepublic String objectToSql(Object value, Database database) {if ((value == null) || "null".equals(value.toString().toLowerCase(Locale.US))) {return null;}String returnValue;if (value instanceof String) {value = ((String) value).replaceAll("'", "");if ("true".equals(((String) value).toLowerCase(Locale.US)) || "1".equals(value) || "b'1'".equals(((String) value).toLowerCase(Locale.US)) || "t".equals(((String) value).toLowerCase(Locale.US)) || ((String) value).toLowerCase(Locale.US).equals(this.getTrueBooleanValue(database).toLowerCase(Locale.US))) {returnValue = this.getTrueBooleanValue(database);} else if ("false".equals(((String) value).toLowerCase(Locale.US)) || "0".equals(value) || "b'0'".equals(((String) value).toLowerCase(Locale.US)) || "f".equals(((String) value).toLowerCase(Locale.US)) || ((String) value).toLowerCase(Locale.US).equals(this.getFalseBooleanValue(database).toLowerCase(Locale.US))) {returnValue = this.getFalseBooleanValue(database);} else {throw new UnexpectedLiquibaseException("Unknown boolean value: " + value);}} else if (value instanceof Long) {if (Long.valueOf(1).equals(value)) {returnValue = this.getTrueBooleanValue(database);} else {returnValue = this.getFalseBooleanValue(database);}} else if (value instanceof Number) {if (value.equals(1) || "1".equals(value.toString()) || "1.0".equals(value.toString())) {returnValue = this.getTrueBooleanValue(database);} else {returnValue = this.getFalseBooleanValue(database);}} else if (value instanceof DatabaseFunction) {return value.toString();} else if (value instanceof Boolean) {if (((Boolean) value)) {returnValue = this.getTrueBooleanValue(database);} else {returnValue = this.getFalseBooleanValue(database);}} else {throw new UnexpectedLiquibaseException("Cannot convert type " + value.getClass() + " to a boolean value");}return returnValue;}protected boolean isNumericBoolean(Database database) {if (database instanceof DerbyDatabase) {return !((DerbyDatabase) database).supportsBooleanDataType();} else if (database.getClass().isAssignableFrom(DB2Database.class)) {return !((DB2Database) database).supportsBooleanDataType();}return (database instanceof Db2zDatabase) || (database instanceof DB2Database) || (database instanceof FirebirdDatabase) || (database instanceof MSSQLDatabase) || (database instanceof MySQLDatabase) || (database instanceof OracleDatabase) ||(database instanceof SQLiteDatabase) || (database instanceof SybaseASADatabase) || (database instanceof SybaseDatabase) || (database instanceof GaussDatabase);}/*** The database-specific value to use for "false" "boolean" columns.*/public String getFalseBooleanValue(Database database) {if (isNumericBoolean(database)) {return "0";}if (database instanceof InformixDatabase) {return "'f'";}return "FALSE";}/*** The database-specific value to use for "true" "boolean" columns.*/public String getTrueBooleanValue(Database database) {if (isNumericBoolean(database)) {return "1";}if (database instanceof InformixDatabase) {return "'t'";}return "TRUE";}@Overridepublic LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() {return LoadDataChange.LOAD_DATA_TYPE.BOOLEAN;}
}

 步骤四、

1.修改下面jar包代码,打开jar包所在文件夹解压,在如下文件中添加下面的代码

步骤五、

1.重新构建项目,将步骤二对应包下面生成的class文件,复制到解压后的jar包中的如下路径中

步骤六、

1.将解压后的jar包文件夹,重新压缩,注意为zip格式,然后更改后缀名为.jar,在放到maven仓库对应的目录下,刷新maven重新加载依赖

这篇关于flowable兼容Gaussdb数据库的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/695962

相关文章

Spring Security基于数据库验证流程详解

Spring Security 校验流程图 相关解释说明(认真看哦) AbstractAuthenticationProcessingFilter 抽象类 /*** 调用 #requiresAuthentication(HttpServletRequest, HttpServletResponse) 决定是否需要进行验证操作。* 如果需要验证,则会调用 #attemptAuthentica

MySQL数据库宕机,启动不起来,教你一招搞定!

作者介绍:老苏,10余年DBA工作运维经验,擅长Oracle、MySQL、PG、Mongodb数据库运维(如安装迁移,性能优化、故障应急处理等)公众号:老苏畅谈运维欢迎关注本人公众号,更多精彩与您分享。 MySQL数据库宕机,数据页损坏问题,启动不起来,该如何排查和解决,本文将为你说明具体的排查过程。 查看MySQL error日志 查看 MySQL error日志,排查哪个表(表空间

深入理解数据库的 4NF:多值依赖与消除数据异常

在数据库设计中, "范式" 是一个常常被提到的重要概念。许多初学者在学习数据库设计时,经常听到第一范式(1NF)、第二范式(2NF)、第三范式(3NF)以及 BCNF(Boyce-Codd范式)。这些范式都旨在通过消除数据冗余和异常来优化数据库结构。然而,当我们谈到 4NF(第四范式)时,事情变得更加复杂。本文将带你深入了解 多值依赖 和 4NF,帮助你在数据库设计中消除更高级别的异常。 什么是

DM8数据库安装后配置

1 前言 在上篇文章中,我们已经成功将库装好。在安装完成后,为了能够更好地满足应用需求和保障系统的安全稳定运行,通常需要进行一些基本的配置。下面是一些常见的配置项: 数据库服务注册:默认包含14个功能模块,将这些模块注册成服务后,可以更好的启动和管理这些功能;基本的实例参数配置:契合应用场景和发挥系统的最大性能;备份:有备无患;… 2 注册实例服务 注册了实例服务后,可以使用系统服务管理,

速了解MySQL 数据库不同存储引擎

快速了解MySQL 数据库不同存储引擎 MySQL 提供了多种存储引擎,每种存储引擎都有其特定的特性和适用场景。了解这些存储引擎的特性,有助于在设计数据库时做出合理的选择。以下是 MySQL 中几种常用存储引擎的详细介绍。 1. InnoDB 特点: 事务支持:InnoDB 是一个支持 ACID(原子性、一致性、隔离性、持久性)事务的存储引擎。行级锁:使用行级锁来提高并发性,减少锁竞争

zeroclipboard 粘贴板的应用示例, 兼容 Chrome、IE等多浏览器

zeroclipboard单个复制按钮和多个复制按钮的实现方法 最近网站改版想让复制代码功能在多个浏览器上都可以实现,最近看网上不少说我们的代码复制功能不好用的,我们最近将会增加代码高亮等功能,希望大家多多支持我们 zeroclipboard是一个跨浏览器的库类 它利用 Flash 进行复制,所以只要浏览器装有 Flash 就可以运行,而且比 IE 的

开源分布式数据库中间件

转自:https://www.csdn.net/article/2015-07-16/2825228 MyCat:开源分布式数据库中间件 为什么需要MyCat? 虽然云计算时代,传统数据库存在着先天性的弊端,但是NoSQL数据库又无法将其替代。如果传统数据易于扩展,可切分,就可以避免单机(单库)的性能缺陷。 MyCat的目标就是:低成本地将现有的单机数据库和应用平滑迁移到“云”端

ORACLE 11g 创建数据库时 Enterprise Manager配置失败的解决办法 无法打开OEM的解决办法

在win7 64位系统下安装oracle11g,在使用Database configuration Assistant创建数据库时,在创建到85%的时候报错,错误如下: 解决办法: 在listener.ora中增加对BlueAeri-PC或ip地址的侦听,具体步骤如下: 1.启动Net Manager,在“监听程序”--Listener下添加一个地址,主机名写计

MyBatis 切换不同的类型数据库方案

下属案例例当前结合SpringBoot 配置进行讲解。 背景: 实现一个工程里面在部署阶段支持切换不同类型数据库支持。 方案一 数据源配置 关键代码(是什么数据库,该怎么配就怎么配) spring:datasource:name: test# 使用druid数据源type: com.alibaba.druid.pool.DruidDataSource# @需要修改 数据库连接及驱动u

CentOS下mysql数据库data目录迁移

https://my.oschina.net/u/873762/blog/180388        公司新上线一个资讯网站,独立主机,raid5,lamp架构。由于资讯网是面向小行业,初步估计一两年内访问量压力不大,故,在做服务器系统搭建的时候,只是简单分出一个独立的data区作为数据库和网站程序的专区,其他按照linux的默认分区。apache,mysql,php均使用yum安装(也尝试