mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
DialectFactory增加identifyDriver重载
This commit is contained in:
parent
fd2756d09b
commit
300fe3b6fd
@ -3,11 +3,12 @@
|
|||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# 5.8.10.M1 (2022-10-27)
|
# 5.8.10.M1 (2022-11-02)
|
||||||
|
|
||||||
### 🐣新特性
|
### 🐣新特性
|
||||||
* 【http 】 HttpResponse增加getFileNameFromDisposition方法(pr#2676@Github)
|
* 【http 】 HttpResponse增加getFileNameFromDisposition方法(pr#2676@Github)
|
||||||
* 【core 】 FileUtil.copy,当来源为文件时,返回文件而非目录
|
* 【core 】 FileUtil.copy,当来源为文件时,返回文件而非目录
|
||||||
|
* 【db 】 DialectFactory增加identifyDriver重载(issue#I5YWI6@Gitee)
|
||||||
|
|
||||||
### 🐞Bug修复
|
### 🐞Bug修复
|
||||||
* 【db 】 修复分页时order by截断问题(issue#I5X6FM@Gitee)
|
* 【db 】 修复分页时order by截断问题(issue#I5X6FM@Gitee)
|
||||||
|
@ -22,7 +22,6 @@ import java.util.Map;
|
|||||||
* 方言工厂类
|
* 方言工厂类
|
||||||
*
|
*
|
||||||
* @author loolly
|
* @author loolly
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class DialectFactory implements DriverNamePool {
|
public class DialectFactory implements DriverNamePool {
|
||||||
|
|
||||||
@ -80,6 +79,17 @@ public class DialectFactory implements DriverNamePool{
|
|||||||
* @return 驱动
|
* @return 驱动
|
||||||
*/
|
*/
|
||||||
public static String identifyDriver(String nameContainsProductInfo) {
|
public static String identifyDriver(String nameContainsProductInfo) {
|
||||||
|
return identifyDriver(nameContainsProductInfo, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过JDBC URL等信息识别JDBC驱动名
|
||||||
|
*
|
||||||
|
* @param nameContainsProductInfo 包含数据库标识的字符串
|
||||||
|
* @param classLoader 类加载器,{@code null}表示默认上下文的类加载器
|
||||||
|
* @return 驱动
|
||||||
|
*/
|
||||||
|
public static String identifyDriver(String nameContainsProductInfo, ClassLoader classLoader) {
|
||||||
if (StrUtil.isBlank(nameContainsProductInfo)) {
|
if (StrUtil.isBlank(nameContainsProductInfo)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -94,9 +104,9 @@ public class DialectFactory implements DriverNamePool{
|
|||||||
|
|
||||||
String driver = null;
|
String driver = null;
|
||||||
if (nameContainsProductInfo.contains("mysql") || nameContainsProductInfo.contains("cobar")) {
|
if (nameContainsProductInfo.contains("mysql") || nameContainsProductInfo.contains("cobar")) {
|
||||||
driver = ClassLoaderUtil.isPresent(DRIVER_MYSQL_V6) ? DRIVER_MYSQL_V6 : DRIVER_MYSQL;
|
driver = ClassLoaderUtil.isPresent(DRIVER_MYSQL_V6, classLoader) ? DRIVER_MYSQL_V6 : DRIVER_MYSQL;
|
||||||
} else if (nameContainsProductInfo.contains("oracle")) {
|
} else if (nameContainsProductInfo.contains("oracle")) {
|
||||||
driver = ClassLoaderUtil.isPresent(DRIVER_ORACLE) ? DRIVER_ORACLE : DRIVER_ORACLE_OLD;
|
driver = ClassLoaderUtil.isPresent(DRIVER_ORACLE, classLoader) ? DRIVER_ORACLE : DRIVER_ORACLE_OLD;
|
||||||
} else if (nameContainsProductInfo.contains("postgresql")) {
|
} else if (nameContainsProductInfo.contains("postgresql")) {
|
||||||
driver = DRIVER_POSTGRESQL;
|
driver = DRIVER_POSTGRESQL;
|
||||||
} else if (nameContainsProductInfo.contains("sqlite")) {
|
} else if (nameContainsProductInfo.contains("sqlite")) {
|
||||||
@ -161,6 +171,7 @@ public class DialectFactory implements DriverNamePool{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取共享方言
|
* 获取共享方言
|
||||||
|
*
|
||||||
* @param ds 数据源,每一个数据源对应一个唯一方言
|
* @param ds 数据源,每一个数据源对应一个唯一方言
|
||||||
* @return {@link Dialect}方言
|
* @return {@link Dialect}方言
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user