• Activiti兼容达梦数据库


    1. 自定义类继承SpringProcessEngineConfiguration类,重写initDatabaseType方法。
    1. package com.ydtf.cbda.module.cbdacim.improcess.config;
    2. import org.activiti.engine.ActivitiException;
    3. import org.activiti.spring.SpringProcessEngineConfiguration;
    4. import org.slf4j.Logger;
    5. import org.slf4j.LoggerFactory;
    6. import java.sql.Connection;
    7. import java.sql.DatabaseMetaData;
    8. import java.sql.SQLException;
    9. /**
    10. * @author 自定义activiti的数据库连接
    11. * @date 2023/9/14 14:31
    12. */
    13. public class CustomConnectionSpringProcessEngineConfiguration extends SpringProcessEngineConfiguration {
    14. private static Logger log = LoggerFactory.getLogger(CustomConnectionSpringProcessEngineConfiguration.class);
    15. @Override
    16. public void initDatabaseType() {
    17. Connection connection = null;
    18. try {
    19. connection = this.dataSource.getConnection();
    20. DatabaseMetaData databaseMetaData = connection.getMetaData();
    21. String databaseProductName = databaseMetaData.getDatabaseProductName();
    22. log.debug("database product name: '{}'", databaseProductName);
    23. this.databaseType = databaseTypeMappings.getProperty(databaseProductName);
    24. if (databaseProductName.contains("DM DBMS")) {
    25. databaseProductName = "Oracle";
    26. }
    27. databaseType = databaseTypeMappings.getProperty(databaseProductName);
    28. if (this.databaseType == null) {
    29. throw new ActivitiException("couldn't deduct database type from database product name '" + databaseProductName + "'");
    30. }
    31. log.debug("using database type: {}", this.databaseType);
    32. if ("mssql".equals(this.databaseType)) {
    33. this.maxNrOfStatementsInBulkInsert = this.DEFAULT_MAX_NR_OF_STATEMENTS_BULK_INSERT_SQL_SERVER;
    34. }
    35. } catch (SQLException var12) {
    36. log.error("Exception while initializing Database connection", var12);
    37. } finally {
    38. try {
    39. if (connection != null) {
    40. connection.close();
    41. }
    42. } catch (SQLException var11) {
    43. log.error("Exception while closing the Database connection", var11);
    44. }
    45. }
    46. }
    47. }
    2.  修改Activiti启动项配置
    1. package com.ydtf.cbda.module.cbdacim.improcess.config;
    2. import org.activiti.spring.SpringProcessEngineConfiguration;
    3. import org.springframework.beans.factory.annotation.Autowired;
    4. import org.springframework.context.annotation.Bean;
    5. import org.springframework.context.annotation.Configuration;
    6. import org.springframework.context.annotation.Primary;
    7. import org.springframework.core.task.TaskExecutor;
    8. import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
    9. import org.springframework.transaction.PlatformTransactionManager;
    10. import javax.sql.DataSource;
    11. /**
    12. * @author 修改activiti启动配置项
    13. * @date 2023/9/14 14:38
    14. */
    15. @Configuration
    16. public class ActivitiConfigguration {
    17. @Autowired
    18. private DataSource dataSource;
    19. @Autowired
    20. private PlatformTransactionManager transactionManager;
    21. @Bean
    22. public SpringProcessEngineConfiguration getProcessEngineConfiguration() {
    23. SpringProcessEngineConfiguration configuration = new CustomConnectionSpringProcessEngineConfiguration();
    24. configuration.setDataSource(dataSource);
    25. configuration.setTransactionManager(transactionManager);
    26. configuration.setDatabaseSchemaUpdate("true");
    27. return configuration;
    28. }
    29. @Bean
    30. @Primary
    31. public TaskExecutor primaryTaskExecutor(){
    32. return new ThreadPoolTaskExecutor();
    33. }
    34. }
  • 相关阅读:
    ASAN入门参考
    公司新来的实习生问我SpringBoot多个环境的配置方式
    c—线性表
    VBA和VBS之不同
    分布式计算平台
    QT基础 - 文件目录操作
    国庆假期作业6
    C#运算符重载
    独立站优化这一点,转化率提升7%
    `Executor` 接口
  • 原文地址:https://blog.csdn.net/qq_31674229/article/details/132917179