1. bpm 模块整合合并
This commit is contained in:
@@ -5,6 +5,25 @@
|
||||
|
||||
package liquibase.database.core;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.PreparedStatement;
|
||||
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.ResourceBundle;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import liquibase.CatalogAndSchema;
|
||||
import liquibase.GlobalConfiguration;
|
||||
import liquibase.Scope;
|
||||
@@ -23,17 +42,15 @@ import liquibase.statement.UniqueConstraint;
|
||||
import liquibase.statement.core.RawCallStatement;
|
||||
import liquibase.statement.core.RawParameterizedSqlStatement;
|
||||
import liquibase.structure.DatabaseObject;
|
||||
import liquibase.structure.core.*;
|
||||
import liquibase.structure.core.Catalog;
|
||||
import liquibase.structure.core.Column;
|
||||
import liquibase.structure.core.Index;
|
||||
import liquibase.structure.core.PrimaryKey;
|
||||
import liquibase.structure.core.Schema;
|
||||
import liquibase.util.JdbcUtil;
|
||||
import liquibase.util.StringUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class DmDatabase extends AbstractJdbcDatabase {
|
||||
private static final String PROXY_USER_REGEX = ".*(?:thin|oci)\\:(.+)/@.*";
|
||||
public static final Pattern PROXY_USER_PATTERN = Pattern.compile(".*(?:thin|oci)\\:(.+)/@.*");
|
||||
@@ -98,6 +115,7 @@ public class DmDatabase extends AbstractJdbcDatabase {
|
||||
public void setConnection(DatabaseConnection conn) {
|
||||
this.reservedWords.addAll(Arrays.asList("GROUP", "USER", "SESSION", "PASSWORD", "RESOURCE", "START", "SIZE", "UID", "DESC", "ORDER"));
|
||||
Connection sqlConn = null;
|
||||
boolean dmDatabase = false;
|
||||
if (!(conn instanceof OfflineConnection)) {
|
||||
try {
|
||||
if (conn instanceof JdbcConnection) {
|
||||
@@ -124,26 +142,42 @@ public class DmDatabase extends AbstractJdbcDatabase {
|
||||
Scope.getCurrentScope().getLog(this.getClass()).info("Could not set remarks reporting on OracleDatabase: " + e.getMessage());
|
||||
}
|
||||
|
||||
CallableStatement statement = null;
|
||||
|
||||
try {
|
||||
statement = sqlConn.prepareCall("{call DBMS_UTILITY.DB_VERSION(?,?)}");
|
||||
statement.registerOutParameter(1, 12);
|
||||
statement.registerOutParameter(2, 12);
|
||||
statement.execute();
|
||||
String compatibleVersion = statement.getString(2);
|
||||
if (compatibleVersion != null) {
|
||||
Matcher majorVersionMatcher = VERSION_PATTERN.matcher(compatibleVersion);
|
||||
if (majorVersionMatcher.matches()) {
|
||||
this.databaseMajorVersion = Integer.valueOf(majorVersionMatcher.group(1));
|
||||
this.databaseMinorVersion = Integer.valueOf(majorVersionMatcher.group(2));
|
||||
DatabaseMetaData metaData = sqlConn.getMetaData();
|
||||
if (metaData != null) {
|
||||
String productName = metaData.getDatabaseProductName();
|
||||
dmDatabase = productName != null && PRODUCT_NAME.equalsIgnoreCase(productName);
|
||||
if (dmDatabase) {
|
||||
this.databaseMajorVersion = metaData.getDatabaseMajorVersion();
|
||||
this.databaseMinorVersion = metaData.getDatabaseMinorVersion();
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String message = "Cannot read from DBMS_UTILITY.DB_VERSION: " + e.getMessage();
|
||||
Scope.getCurrentScope().getLog(this.getClass()).info("Could not set check compatibility mode on OracleDatabase, assuming not running in any sort of compatibility mode: " + message);
|
||||
} finally {
|
||||
JdbcUtil.closeStatement(statement);
|
||||
Scope.getCurrentScope().getLog(this.getClass()).info("Unable to inspect database metadata for DM version detection: " + e.getMessage());
|
||||
}
|
||||
|
||||
if (!dmDatabase) {
|
||||
CallableStatement statement = null;
|
||||
|
||||
try {
|
||||
statement = sqlConn.prepareCall("{call DBMS_UTILITY.DB_VERSION(?,?)}");
|
||||
statement.registerOutParameter(1, 12);
|
||||
statement.registerOutParameter(2, 12);
|
||||
statement.execute();
|
||||
String compatibleVersion = statement.getString(2);
|
||||
if (compatibleVersion != null) {
|
||||
Matcher majorVersionMatcher = VERSION_PATTERN.matcher(compatibleVersion);
|
||||
if (majorVersionMatcher.matches()) {
|
||||
this.databaseMajorVersion = Integer.valueOf(majorVersionMatcher.group(1));
|
||||
this.databaseMinorVersion = Integer.valueOf(majorVersionMatcher.group(2));
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String message = "Cannot read from DBMS_UTILITY.DB_VERSION: " + e.getMessage();
|
||||
Scope.getCurrentScope().getLog(this.getClass()).info("Could not set check compatibility mode on OracleDatabase, assuming not running in any sort of compatibility mode: " + message);
|
||||
} finally {
|
||||
JdbcUtil.closeStatement(statement);
|
||||
}
|
||||
}
|
||||
|
||||
if (GlobalConfiguration.DDL_LOCK_TIMEOUT.getCurrentValue() != null) {
|
||||
@@ -250,7 +284,15 @@ public class DmDatabase extends AbstractJdbcDatabase {
|
||||
}
|
||||
|
||||
public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws DatabaseException {
|
||||
return "oracle".equalsIgnoreCase(conn.getDatabaseProductName());
|
||||
String databaseProductName = conn == null ? null : conn.getDatabaseProductName();
|
||||
if (databaseProductName == null) {
|
||||
return false;
|
||||
}
|
||||
if (PRODUCT_NAME.equalsIgnoreCase(databaseProductName)) {
|
||||
return true;
|
||||
}
|
||||
// Flowable 历史上将 DM 映射为 Oracle 元数据,因此这里同样接受 Oracle 以保持兼容
|
||||
return "oracle".equalsIgnoreCase(databaseProductName);
|
||||
}
|
||||
|
||||
public String getDefaultDriver(String url) {
|
||||
|
||||
Reference in New Issue
Block a user