mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix bug
This commit is contained in:
parent
78aaab53bc
commit
d60b315a20
@ -3,7 +3,7 @@
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# 5.6.3 (2021-04-03)
|
||||
# 5.6.3 (2021-04-04)
|
||||
|
||||
### 新特性
|
||||
* 【core 】 修改数字转换的实现,增加按照指定端序转换(pr#1492@Github)
|
||||
@ -13,6 +13,7 @@
|
||||
|
||||
### Bug修复
|
||||
* 【core 】 修复Validator.isUrl()传空返回true(issue#I3ETTY@Gitee)
|
||||
* 【db 】 修复数据库driver根据url的判断识别错误问题(issue#I3EWBI@Gitee)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.hutool.db.dialect;
|
||||
|
||||
import cn.hutool.core.util.ClassLoaderUtil;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.db.dialect.impl.AnsiSqlDialect;
|
||||
import cn.hutool.db.dialect.impl.H2Dialect;
|
||||
@ -115,6 +116,12 @@ public class DialectFactory {
|
||||
// 全部转为小写,忽略大小写
|
||||
nameContainsProductInfo = StrUtil.cleanBlank(nameContainsProductInfo.toLowerCase());
|
||||
|
||||
// 首先判断是否为标准的JDBC URL,截取jdbc:xxxx:中间部分
|
||||
final String name = ReUtil.getGroup1("jdbc:(.*?):", nameContainsProductInfo);
|
||||
if(StrUtil.isNotBlank(name)){
|
||||
nameContainsProductInfo = name;
|
||||
}
|
||||
|
||||
String driver = null;
|
||||
if (nameContainsProductInfo.contains("mysql")) {
|
||||
driver = ClassLoaderUtil.isPresent(DRIVER_MYSQL_V6) ? DRIVER_MYSQL_V6 : DRIVER_MYSQL;
|
||||
|
@ -0,0 +1,14 @@
|
||||
package cn.hutool.db.dialect;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DriverUtilTest {
|
||||
|
||||
@Test
|
||||
public void identifyDriverTest(){
|
||||
String url = "jdbc:h2:file:./db/test;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE;MODE=MYSQL";
|
||||
String driver = DriverUtil.identifyDriver(url); // driver 返回 mysql 的 driver
|
||||
Assert.assertEquals("org.h2.Driver", driver);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user