【代码评审】Framework:find in set 代码

This commit is contained in:
YunaiV 2024-06-22 10:52:42 +08:00
parent 5f9d4b36a7
commit 355e47c371
2 changed files with 2 additions and 5 deletions

View File

@ -9,6 +9,7 @@ import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;
// TODO @dhb52是不是把 FindInSetEnumNameToTypeEnum 融合搞成 DbTypeEnum然后里面 typeproductNamefindInSet
/**
* 数据库产品名 => mp DbType 的映射关系
*

View File

@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.annotation.DbType;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;
@ -53,10 +52,7 @@ public class JdbcUtils {
DynamicRoutingDataSource dynamicRoutingDataSource = SpringUtils.getBean(DynamicRoutingDataSource.class);
DataSource dataSource = dynamicRoutingDataSource.determineDataSource();
try (Connection conn = dataSource.getConnection()) {
DatabaseMetaData metaData = conn.getMetaData();
String databaseProductName = metaData.getDatabaseProductName();
DbType dbType = NameToTypeEnum.find(databaseProductName);
return dbType;
return NameToTypeEnum.find(conn.getMetaData().getDatabaseProductName());
} catch (SQLException e) {
throw new IllegalArgumentException(e.getMessage());
}