mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 20:49:00 +08:00
feat(flowable): 升级Flowable版本至7.2.0并重构数据库工具类
- 将Flowable依赖版本从7.0.0升级至7.2.0 - 提取AbstractEngineConfiguration中的数据库类型映射逻辑到独立工具类DbUtil - 新增DbUtil工具类封装数据库类型检测和映射功能 - 删除过时的AbstractEngineConfiguration实现类
This commit is contained in:
1 parent
1bb0af7b52
commit
f4508ac412
3 files changed
+127
-2165
No files matched your search
@@ -32,7 +32,7 @@
|
||||
<javax.version>4.0.1</javax.version>
|
||||
<jsoup.version>1.15.3</jsoup.version>
|
||||
<aviator.version>5.4.3</aviator.version>
|
||||
<flowable.version>7.0.0</flowable.version>
|
||||
<flowable.version>7.2.0</flowable.version>
|
||||
<security.oauth.version>2.5.2.RELEASE</security.oauth.version>
|
||||
<fastjson.version>1.2.83</fastjson.version>
|
||||
<xxl.job.version>2.4.2</xxl.job.version>
|
||||
|
||||
-2164
File diff suppressed because it is too large.
Load diff
+126
@@ -0,0 +1,126 @@
|
||||
/* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.flowable.common.engine.impl.util;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.flowable.common.engine.api.FlowableException;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.*;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author Filip Hrisafov
|
||||
*/
|
||||
public class DbUtil {
|
||||
|
||||
public static final String PRODUCT_NAME_POSTGRES = "PostgreSQL";
|
||||
public static final String PRODUCT_NAME_CRDB = "CockroachDB";
|
||||
|
||||
public static final String DATABASE_TYPE_H2 = "h2";
|
||||
public static final String DATABASE_TYPE_HSQL = "hsql";
|
||||
public static final String DATABASE_TYPE_MYSQL = "mysql";
|
||||
public static final String DATABASE_TYPE_ORACLE = "oracle";
|
||||
public static final String DATABASE_TYPE_POSTGRES = "postgres";
|
||||
public static final String DATABASE_TYPE_MSSQL = "mssql";
|
||||
public static final String DATABASE_TYPE_DB2 = "db2";
|
||||
public static final String DATABASE_TYPE_COCKROACHDB = "cockroachdb";
|
||||
|
||||
public static Properties getDefaultDatabaseTypeMappings() {
|
||||
Properties databaseTypeMappings = new Properties();
|
||||
databaseTypeMappings.setProperty("H2", DATABASE_TYPE_H2);
|
||||
databaseTypeMappings.setProperty("HSQL Database Engine", DATABASE_TYPE_HSQL);
|
||||
databaseTypeMappings.setProperty("MySQL", DATABASE_TYPE_MYSQL);
|
||||
databaseTypeMappings.setProperty("MariaDB", DATABASE_TYPE_MYSQL);
|
||||
databaseTypeMappings.setProperty("Oracle", DATABASE_TYPE_ORACLE);
|
||||
databaseTypeMappings.setProperty(PRODUCT_NAME_POSTGRES, DATABASE_TYPE_POSTGRES);
|
||||
databaseTypeMappings.setProperty("Microsoft SQL Server", DATABASE_TYPE_MSSQL);
|
||||
databaseTypeMappings.setProperty(DATABASE_TYPE_DB2, DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2/NT", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2/NT64", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2 UDP", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2/LINUX", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2/LINUX390", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2/LINUXX8664", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2/LINUXZ64", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2/LINUXPPC64", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2/LINUXPPC64LE", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2/400 SQL", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2/6000", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2 UDB iSeries", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2/AIX64", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2/HPUX", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2/HP64", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2/SUN", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2/SUN64", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2/PTX", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2/2", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DB2 UDB AS400", DATABASE_TYPE_DB2);
|
||||
databaseTypeMappings.setProperty("DM DBMS", DATABASE_TYPE_MYSQL);// 扩展支持达梦数据
|
||||
databaseTypeMappings.setProperty("KingbaseES", DATABASE_TYPE_POSTGRES);// 扩展支持人大金仓
|
||||
databaseTypeMappings.setProperty(PRODUCT_NAME_CRDB, DATABASE_TYPE_COCKROACHDB);
|
||||
return databaseTypeMappings;
|
||||
}
|
||||
|
||||
public static String determineDatabaseType(DataSource dataSource, Logger logger) {
|
||||
return determineDatabaseType(dataSource, logger, getDefaultDatabaseTypeMappings());
|
||||
}
|
||||
|
||||
public static String determineDatabaseType(DataSource dataSource, Logger logger, Properties databaseTypeMappings) {
|
||||
Connection connection = null;
|
||||
String databaseType = null;
|
||||
try {
|
||||
connection = dataSource.getConnection();
|
||||
DatabaseMetaData databaseMetaData = connection.getMetaData();
|
||||
String databaseProductName = databaseMetaData.getDatabaseProductName();
|
||||
logger.debug("database product name: '{}'", databaseProductName);
|
||||
|
||||
// CRDB does not expose the version through the jdbc driver, so we need to fetch it through version().
|
||||
if (PRODUCT_NAME_POSTGRES.equalsIgnoreCase(databaseProductName)) {
|
||||
try (PreparedStatement preparedStatement = connection.prepareStatement("select version() as version;"); ResultSet resultSet = preparedStatement.executeQuery()) {
|
||||
String version = null;
|
||||
if (resultSet.next()) {
|
||||
version = resultSet.getString("version");
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(version) && version.toLowerCase().startsWith(PRODUCT_NAME_CRDB.toLowerCase())) {
|
||||
databaseProductName = PRODUCT_NAME_CRDB;
|
||||
logger.info("CockroachDB version '{}' detected", version);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
databaseType = databaseTypeMappings.getProperty(databaseProductName);
|
||||
if (databaseType == null) {
|
||||
throw new FlowableException("couldn't deduct database type from database product name '" + databaseProductName + "'");
|
||||
}
|
||||
logger.debug("using database type: {}", databaseType);
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException("Exception while initializing Database connection", e);
|
||||
} finally {
|
||||
try {
|
||||
if (connection != null) {
|
||||
connection.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
logger.error("Exception while closing the Database connection", e);
|
||||
}
|
||||
}
|
||||
|
||||
return databaseType;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user