mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-04-12 05:23:16 +08:00
fix 修复 代码生成 主库生成其他不同数据源sql模板错误问题
This commit is contained in:
@@ -46,6 +46,24 @@ public class DataBaseHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定数据源对应的数据库类型
|
||||
*
|
||||
* @param dsName 数据源名称
|
||||
* @return 指定数据库对应的 DataBaseType 枚举,找不到时默认返回 MY_SQL
|
||||
* @throws ServiceException 当获取数据库连接或元数据出现异常时抛出业务异常
|
||||
*/
|
||||
public static DataBaseType getDataBaseType(String dsName) {
|
||||
DataSource dataSource = DS.getDataSource(dsName);
|
||||
try (Connection conn = dataSource.getConnection()) {
|
||||
DatabaseMetaData metaData = conn.getMetaData();
|
||||
String databaseProductName = metaData.getDatabaseProductName();
|
||||
return DataBaseType.find(databaseProductName);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException("获取数据库类型失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前数据库类型,生成兼容的 FIND_IN_SET 语句片段
|
||||
* <p>
|
||||
|
||||
Reference in New Issue
Block a user