camunda7.14修改为MySQL(免费修改照片大小kb)

开源流程引擎camunda官方支持的数据库有:MySQL 、MariaDB 、Oracle 、DB2 、PostgreSQL 、SQL Server、H2。默认不支持国产数据库/信创数据库,有需求的项目需要自己适配,下面以达梦数据库适配为例进行介绍。对于其他国产数据库如人大金仓、神州通用、高斯数据库(GaussDB)、优炫数据库等也是同样的修改方法,只是需要注意一下对应数据库的方言即可。

camunda7.14修改为MySQL(免费修改照片大小kb)

一、引入达梦数据库驱动包

在maven工程的Resources目录下建lib目录,放入达梦数据库驱动包Dm7JdbcDriver17.jar,并配置maven为本地引用dm.jdbc.driver.DmDriverjdbcsystem${project.basedir}/src/main/resources/lib/Dm7JdbcDriver17.jar

二、配置达梦数据源

url: jdbc:dm://127.0.0.1:5236username: oapassword: 12345678aAdriver-class-name: dm.jdbc.driver.DmDriver

三、修改camunda代码,支持达梦数据库

1. 修改ProcessEngineConfigurationImpl类的代码

在org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl类的getDefaultDatabaseTypeMappings方法里增加databaseTypeMappings.setProperty(“DM DBMS”, “dm”);

protected static Properties getDefaultDatabaseTypeMappings() {       Properties databaseTypeMappings = new Properties();    databaseTypeMappings.setProperty("H2", "h2");    databaseTypeMappings.setProperty(MY_SQL_PRODUCT_NAME, "mysql");    databaseTypeMappings.setProperty(MARIA_DB_PRODUCT_NAME, "mariadb");    databaseTypeMappings.setProperty("Oracle", "oracle");    databaseTypeMappings.setProperty("PostgreSQL", "postgres");    databaseTypeMappings.setProperty("Microsoft SQL Server", "mssql");    databaseTypeMappings.setProperty("DB2", "db2");    databaseTypeMappings.setProperty("DB2", "db2");    databaseTypeMappings.setProperty("DB2/NT", "db2");    databaseTypeMappings.setProperty("DB2/NT64", "db2");    databaseTypeMappings.setProperty("DB2 UDP", "db2");    databaseTypeMappings.setProperty("DB2/LINUX", "db2");    databaseTypeMappings.setProperty("DB2/LINUX390", "db2");    databaseTypeMappings.setProperty("DB2/LINUXX8664", "db2");    databaseTypeMappings.setProperty("DB2/LINUXZ64", "db2");    databaseTypeMappings.setProperty("DB2/400 SQL", "db2");    databaseTypeMappings.setProperty("DB2/6000", "db2");    databaseTypeMappings.setProperty("DB2 UDB iSeries", "db2");    databaseTypeMappings.setProperty("DB2/AIX64", "db2");    databaseTypeMappings.setProperty("DB2/HPUX", "db2");    databaseTypeMappings.setProperty("DB2/HP64", "db2");    databaseTypeMappings.setProperty("DB2/SUN", "db2");    databaseTypeMappings.setProperty("DB2/SUN64", "db2");    databaseTypeMappings.setProperty("DB2/PTX", "db2");    databaseTypeMappings.setProperty("DB2/2", "db2");    databaseTypeMappings.setProperty("DM DBMS", "dm"); //达梦    return databaseTypeMappings;  }

2. 修改DbSqlSessionFactory类代码

org.camunda.bpm.engine.impl.db.sql.DbSqlSessionFactory类里增加对达梦数据库的语法解析。public static final String DMDBMS = “dm”;//达梦数据库public static final String[] SUPPORTED_DATABASES = {MSSQL, DB2, ORACLE, H2, MYSQL, POSTGRES, MARIADB, DMDBMS};

public class DbSqlSessionFactory implements SessionFactory {     public static final String MSSQL = "mssql";  public static final String DB2 = "db2";  public static final String ORACLE = "oracle";  public static final String H2 = "h2";  public static final String MYSQL = "mysql";  public static final String POSTGRES = "postgres";  public static final String MARIADB = "mariadb";  public static final String DMDBMS = "dm";//达梦数据库  public static final String[] SUPPORTED_DATABASES = {   MSSQL, DB2, ORACLE, H2, MYSQL, POSTGRES, MARIADB, DMDBMS};

并在static方法里增加:

databaseSpecificLimitBeforeStatements.put(DMDBMS, "select * from ( select a.*, ROWNUM rnum from (");    optimizeDatabaseSpecificLimitBeforeWithoutOffsetStatements.put(DMDBMS, "select * from ( select a.*, ROWNUM rnum from (");    databaseSpecificLimitAfterStatements.put(DMDBMS, " ) a where ROWNUM < #{lastRow}) where rnum >= #{firstRow}");    optimizeDatabaseSpecificLimitAfterWithoutOffsetStatements.put(DMDBMS, " ) a where ROWNUM <= #{maxResults})");    databaseSpecificLimitBeforeWithoutOffsetStatements.put(DMDBMS, "");    databaseSpecificLimitAfterWithoutOffsetStatements.put(DMDBMS, "AND ROWNUM <= #{maxResults}");    databaseSpecificInnerLimitAfterStatements.put(DMDBMS, databaseSpecificLimitAfterStatements.get(DMDBMS));    databaseSpecificLimitBetweenStatements.put(DMDBMS, "");    databaseSpecificLimitBetweenFilterStatements.put(DMDBMS, "");    databaseSpecificOrderByStatements.put(DMDBMS, defaultOrderBy);    databaseSpecificLimitBeforeNativeQueryStatements.put(DMDBMS, "");    databaseSpecificDistinct.put(DMDBMS, "distinct");    databaseSpecificEscapeChar.put(DMDBMS, defaultEscapeChar);    databaseSpecificDummyTable.put(DMDBMS, "FROM DUAL");    databaseSpecificBitAnd1.put(DMDBMS, "BITAND(");    databaseSpecificBitAnd2.put(DMDBMS, ",");    databaseSpecificBitAnd3.put(DMDBMS, ")");    databaseSpecificDatepart1.put(DMDBMS, "to_number(to_char(");    databaseSpecificDatepart2.put(DMDBMS, ",");    databaseSpecificDatepart3.put(DMDBMS, "))");    databaseSpecificTrueConstant.put(DMDBMS, "1");    databaseSpecificFalseConstant.put(DMDBMS, "0");    databaseSpecificIfNull.put(DMDBMS, "NVL");    databaseSpecificDaysComparator.put(DMDBMS, "${date} <= #{currentTimestamp} - ${days}");    databaseSpecificCollationForCaseSensitivity.put(DMDBMS, "");    addDatabaseSpecificStatement(DMDBMS, "selectHistoricProcessInstanceDurationReport", "selectHistoricProcessInstanceDurationReport_oracle");    addDatabaseSpecificStatement(DMDBMS, "selectHistoricTaskInstanceDurationReport", "selectHistoricTaskInstanceDurationReport_oracle");    addDatabaseSpecificStatement(DMDBMS, "selectHistoricTaskInstanceCountByTaskNameReport", "selectHistoricTaskInstanceCountByTaskNameReport_oracle");    addDatabaseSpecificStatement(DMDBMS, "selectFilterByQueryCriteria", "selectFilterByQueryCriteria_oracleDb2");    addDatabaseSpecificStatement(DMDBMS, "selectHistoricProcessInstanceIdsForCleanup", "selectHistoricProcessInstanceIdsForCleanup_oracle");    addDatabaseSpecificStatement(DMDBMS, "selectHistoricDecisionInstanceIdsForCleanup", "selectHistoricDecisionInstanceIdsForCleanup_oracle");    addDatabaseSpecificStatement(DMDBMS, "selectHistoricCaseInstanceIdsForCleanup", "selectHistoricCaseInstanceIdsForCleanup_oracle");    addDatabaseSpecificStatement(DMDBMS, "selectHistoricBatchIdsForCleanup", "selectHistoricBatchIdsForCleanup_oracle");    addDatabaseSpecificStatement(DMDBMS, "deleteAttachmentsByRemovalTime", "deleteAttachmentsByRemovalTime_oracle");    addDatabaseSpecificStatement(DMDBMS, "deleteCommentsByRemovalTime", "deleteCommentsByRemovalTime_oracle");    addDatabaseSpecificStatement(DMDBMS, "deleteHistoricActivityInstancesByRemovalTime", "deleteHistoricActivityInstancesByRemovalTime_oracle");    addDatabaseSpecificStatement(DMDBMS, "deleteHistoricDecisionInputInstancesByRemovalTime", "deleteHistoricDecisionInputInstancesByRemovalTime_oracle");    addDatabaseSpecificStatement(DMDBMS, "deleteHistoricDecisionInstancesByRemovalTime", "deleteHistoricDecisionInstancesByRemovalTime_oracle");    addDatabaseSpecificStatement(DMDBMS, "deleteHistoricDecisionOutputInstancesByRemovalTime", "deleteHistoricDecisionOutputInstancesByRemovalTime_oracle");    addDatabaseSpecificStatement(DMDBMS, "deleteHistoricDetailsByRemovalTime", "deleteHistoricDetailsByRemovalTime_oracle");    addDatabaseSpecificStatement(DMDBMS, "deleteExternalTaskLogByRemovalTime", "deleteExternalTaskLogByRemovalTime_oracle");    addDatabaseSpecificStatement(DMDBMS, "deleteHistoricIdentityLinkLogByRemovalTime", "deleteHistoricIdentityLinkLogByRemovalTime_oracle");    addDatabaseSpecificStatement(DMDBMS, "deleteHistoricIncidentsByRemovalTime", "deleteHistoricIncidentsByRemovalTime_oracle");    addDatabaseSpecificStatement(DMDBMS, "deleteJobLogByRemovalTime", "deleteJobLogByRemovalTime_oracle");    addDatabaseSpecificStatement(DMDBMS, "deleteHistoricProcessInstancesByRemovalTime", "deleteHistoricProcessInstancesByRemovalTime_oracle");    addDatabaseSpecificStatement(DMDBMS, "deleteHistoricTaskInstancesByRemovalTime", "deleteHistoricTaskInstancesByRemovalTime_oracle");    addDatabaseSpecificStatement(DMDBMS, "deleteHistoricVariableInstancesByRemovalTime", "deleteHistoricVariableInstancesByRemovalTime_oracle");    addDatabaseSpecificStatement(DMDBMS, "deleteUserOperationLogByRemovalTime", "deleteUserOperationLogByRemovalTime_oracle");    addDatabaseSpecificStatement(DMDBMS, "deleteByteArraysByRemovalTime", "deleteByteArraysByRemovalTime_oracle");    addDatabaseSpecificStatement(DMDBMS, "deleteHistoricBatchesByRemovalTime", "deleteHistoricBatchesByRemovalTime_oracle");    constants = new HashMap<String, String>();    constants.put("constant.event", "cast('event' as nvarchar2(255))");    constants.put("constant.op_message", "NEW_VALUE_ || '_|_' || PROPERTY_");    constants.put("constant_for_update", "for update");    constants.put("constant.datepart.quarter", "'Q'");    constants.put("constant.datepart.month", "'MM'");    constants.put("constant.datepart.minute", "'MI'");    constants.put("constant.null.startTime", "null START_TIME_");    constants.put("constant.varchar.cast", "'${key}'");    constants.put("constant.integer.cast", "NULL");    constants.put("constant.null.reporter", "NULL AS REPORTER_");    dbSpecificConstants.put(DMDBMS, constants);

四、修改数据库连接池

如果工程中使用的是阿里巴巴的druid连接池,可能会报如下错误:Cause: java.lang.IllegalStateException: dbType not support : dm需要把sql防火墙等功能关闭掉即解决该问题:spring.datasource.filters=stat,wall,log4j把这个配置里的wall去掉。

本站部分内容由互联网用户自发贡献,该文观点仅代表作者本人,本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。

如发现本站有涉嫌抄袭侵权/违法违规等内容,请联系我们举报!一经查实,本站将立刻删除。