diff --git a/pom.xml b/pom.xml
index 6837e176..5fd93721 100644
--- a/pom.xml
+++ b/pom.xml
@@ -78,7 +78,7 @@
com.dameng
DmJdbcDriver18
- 8.1.1.193
+ 8.1.2.192
com.oracle
diff --git a/zyplayer-doc-db/src/main/java/com/zyplayer/doc/db/controller/DbSqlExecutorController.java b/zyplayer-doc-db/src/main/java/com/zyplayer/doc/db/controller/DbSqlExecutorController.java
index 9315bd47..140112e0 100644
--- a/zyplayer-doc-db/src/main/java/com/zyplayer/doc/db/controller/DbSqlExecutorController.java
+++ b/zyplayer-doc-db/src/main/java/com/zyplayer/doc/db/controller/DbSqlExecutorController.java
@@ -1,13 +1,11 @@
package com.zyplayer.doc.db.controller;
+import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.ast.SQLStatement;
-import com.alibaba.druid.sql.ast.statement.SQLSelectStatement;
-import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser;
+import com.alibaba.druid.sql.parser.SQLStatementParser;
import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.zyplayer.doc.core.annotation.AuthMan;
-import com.zyplayer.doc.core.exception.ConfirmException;
import com.zyplayer.doc.data.config.security.DocUserDetails;
import com.zyplayer.doc.data.config.security.DocUserUtil;
import com.zyplayer.doc.data.repository.manage.entity.DbFavorite;
@@ -21,8 +19,7 @@ import com.zyplayer.doc.db.framework.consts.DbAuthType;
import com.zyplayer.doc.db.framework.db.mapper.base.*;
import com.zyplayer.doc.db.framework.db.transfer.SqlParseUtil;
import com.zyplayer.doc.db.framework.json.DocDbResponseJson;
-import com.zyplayer.doc.db.framework.utils.JSONUtil;
-import com.zyplayer.doc.db.framework.utils.SqlLogUtil;
+import com.zyplayer.doc.db.framework.utils.SQLTransformUtils;
import com.zyplayer.doc.db.service.database.DatabaseServiceFactory;
import com.zyplayer.doc.db.service.database.DbBaseService;
import org.apache.commons.lang3.StringUtils;
@@ -76,7 +73,11 @@ public class DbSqlExecutorController {
// 解析出多个执行的SQL
List analysisQuerySqlList = new LinkedList<>();
try {
- List sqlStatements = new MySqlStatementParser(sql).parseStatementList();
+ String driverClassName = dbBaseService.getDatabaseProduct().getDriverClassName();
+ List sqlStatements = new ArrayList();
+ //根据驱动程序类名获取数据库类型
+ DbType dbType = SQLTransformUtils.getDbTypeByDriverClassName(driverClassName);
+ sqlStatements = new SQLStatementParser(sql,dbType).parseStatementList();
for (SQLStatement sqlStatement : sqlStatements) {
analysisQuerySqlList.add(sqlStatement.toString());
}
diff --git a/zyplayer-doc-db/src/main/java/com/zyplayer/doc/db/framework/utils/SQLTransformUtils.java b/zyplayer-doc-db/src/main/java/com/zyplayer/doc/db/framework/utils/SQLTransformUtils.java
index a775b85b..cc827f5e 100644
--- a/zyplayer-doc-db/src/main/java/com/zyplayer/doc/db/framework/utils/SQLTransformUtils.java
+++ b/zyplayer-doc-db/src/main/java/com/zyplayer/doc/db/framework/utils/SQLTransformUtils.java
@@ -7,7 +7,7 @@ import com.alibaba.druid.sql.dialect.mysql.parser.MySqlLexer;
import com.alibaba.druid.sql.dialect.oracle.parser.OracleLexer;
import com.alibaba.druid.sql.dialect.sqlserver.parser.SQLServerLexer;
import com.alibaba.druid.sql.parser.Keywords;
-import com.alibaba.druid.sql.parser.Lexer;
+import com.zyplayer.doc.db.framework.db.enums.DatabaseProductEnum;
import com.zyplayer.doc.db.framework.db.sql.dialect.mysql.MySqlToOracleOutputVisitor;
import com.zyplayer.doc.db.framework.db.sql.dialect.mysql.MySqlToSqlServerOutputVisitor;
import com.zyplayer.doc.db.framework.db.sql.dialect.oracle.OracleToMySqlOutputVisitor;
@@ -145,4 +145,29 @@ public class SQLTransformUtils {
}
return Keywords.DEFAULT_KEYWORDS.getKeywords().containsKey(name.toUpperCase());
}
+
+ /**
+ * 根据驱动程序类名获取数据库类型
+ * @param driverClassName 驱动程序类名
+ * @return DbType 数据库类型
+ */
+ public static DbType getDbTypeByDriverClassName(String driverClassName) {
+ DbType dbType;
+ if(driverClassName.equalsIgnoreCase(DatabaseProductEnum.MYSQL.name())){
+ dbType = DbType.mysql;
+ }else if(driverClassName.equalsIgnoreCase(DatabaseProductEnum.ORACLE.name())){
+ dbType = DbType.oracle;
+ }else if(driverClassName.equalsIgnoreCase(DatabaseProductEnum.DM.name())){
+ dbType = DbType.dm;
+ }else if(driverClassName.equalsIgnoreCase(DatabaseProductEnum.SQLSERVER.name())){
+ dbType = DbType.sqlserver;
+ }else if(driverClassName.equalsIgnoreCase(DatabaseProductEnum.POSTGRESQL.name())){
+ dbType = DbType.postgresql;
+ }else if(driverClassName.equalsIgnoreCase(DatabaseProductEnum.HIVE.name())){
+ dbType = DbType.hive;
+ }else{
+ dbType = DbType.other;
+ }
+ return dbType;
+ }
}