java - 如何同时加载2种JDBC驱动
大家讲道理
大家讲道理 2017-04-18 09:39:17
0
2
505

在代码中同时添加了sqlserver2008sqlserver2000jdbc的jar包,并且生成了2个连接池对象,每个连接池对象都设置了不同的DriverClass,但是启动的时候依然提示以下错误

2016-7-28 16:02:16 com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
警告: ConnectionID:5 ClientConnectionId: 88e86cb1-2464-4d23-be03-9beec06a5e2d Server major version:8 is not supported by this driver.

sqlserver2000依旧使用更高级别的DriverClass加载,如何才能做到同时加载2种不同版本的sqlserver的DriverClass

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
巴扎黑

Is it java? Are you using spring? If you want to use different jar packages, you actually want to connect to two different databases at the same time, right? If it is spring, please configure two data sources with different names and use them separately

Ty80

The question here is related to the class loading mechanism, which is generally JDBC 的驱动都是会用 Class.forName("包名.类名") 进行加载,如果两个版本的 JDBC 驱动的包名和类名是一样的,那只能加载其中一个 DriverClass.

It’s very simple to understand this, then just change different package names

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!