mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
【代码评审】Framework:find in set 代码
This commit is contained in:
parent
5f9d4b36a7
commit
355e47c371
@ -9,6 +9,7 @@ import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
// TODO @dhb52:是不是把 FindInSetEnum、NameToTypeEnum 融合,搞成 DbTypeEnum?然后里面 type、productName,findInSet
|
||||
/**
|
||||
* 数据库产品名 => mp DbType 的映射关系
|
||||
*
|
||||
|
@ -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());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user