mirror of
				https://gitee.com/dromara/hutool.git
				synced 2025-10-26 18:59:23 +08:00 
			
		
		
		
	修复PooledConnection可能的数据库驱动未找到问题
This commit is contained in:
		| @@ -1,6 +1,9 @@ | ||||
| package cn.hutool.db.ds.pooled; | ||||
|  | ||||
| import cn.hutool.core.map.MapUtil; | ||||
| import cn.hutool.core.util.ClassUtil; | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import cn.hutool.db.DbRuntimeException; | ||||
| import cn.hutool.db.DbUtil; | ||||
| import cn.hutool.setting.dialect.Props; | ||||
|  | ||||
| @@ -15,7 +18,7 @@ import java.util.Properties; | ||||
|  * | ||||
|  */ | ||||
| public class PooledConnection extends ConnectionWraper{ | ||||
| 	 | ||||
|  | ||||
| 	private final PooledDataSource ds; | ||||
| 	private boolean isClosed; | ||||
|  | ||||
| @@ -29,6 +32,16 @@ public class PooledConnection extends ConnectionWraper{ | ||||
| 		this.ds = ds; | ||||
| 		final DbConfig config = ds.getConfig(); | ||||
|  | ||||
| 		// issue#IA6EUQ 部分驱动无法自动加载,此处手动完成 | ||||
| 		final String driver = config.getDriver(); | ||||
| 		if(StrUtil.isNotBlank(driver)){ | ||||
| 			try { | ||||
| 				Class.forName(driver); | ||||
| 			} catch (ClassNotFoundException e) { | ||||
| 				throw new DbRuntimeException(e); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		final Props info = new Props(); | ||||
| 		final String user = config.getUser(); | ||||
| 		if (user != null) { | ||||
| @@ -47,7 +60,7 @@ public class PooledConnection extends ConnectionWraper{ | ||||
|  | ||||
| 		this.raw = DriverManager.getConnection(config.getUrl(), info); | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	public PooledConnection(PooledDataSource ds, Connection conn) { | ||||
| 		this.ds = ds; | ||||
| 		this.raw = conn; | ||||
| @@ -71,7 +84,7 @@ public class PooledConnection extends ConnectionWraper{ | ||||
| 	public boolean isClosed() throws SQLException { | ||||
| 		return isClosed || raw.isClosed(); | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	/** | ||||
| 	 * 打开连接 | ||||
| 	 * @return this | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Looly
					Looly