Summary of the premise: A project needs to do a query page, but there are multiple query libraries, and there are many kinds: oracle , SqlServer and pg , so configuring the data source has also become a problem, because the weblogic version is version 10.3.2 , there is no sqlserver 's jdbc driver, so you need to add a driver to configure.
1. Middleware and database information
Middleware: weblogic 10.3.2.0
Database: sqlserver 2014
ip:10.10.10.10
port:8888
Database name when the client connects: GCCDB
Database name when the code connects: UMPDB
User: dbuser
Password: 123456ABc
2. Download the jdbc package of sqlserver and configure it
( 1 ) Official search from Microsoft: SQL Server JDBC Driver
( 2 ) Select: Microsoft JDBC Driver 4.0 for SQL Server
• Sqljdbc4.jar requires JRE 6 and supports JDBC 4.0 API
Supported SQL Server Versions:
• Microsoft SQL Server 2016
• Microsoft SQL Server 2014
( 3 ) Download address: https://www.microsoft.com/zh-cn/download/details.aspx?id=54629
(4) Copy the sqlserver4.jar package to the target directory :
Select sqlserver4.jar and put it in the C:\Oracle\Middleware\wlserver_10.3\common\lib directory
Configure WEBLOGIC_CLASSPATH in the commEnv.cmd file under C:\Oracle\Middleware\wlserver_10.3\common\bin, and add ";%WL_HOME%\common\lib\sqljdbc4.jar" at the end
Don't forget to separate with semicolons! ! !
Note: When weblogic starts, the sqlserver4.jar of this configuration item will be loaded
3 , weblogic configuration steps
( 1 ) Data source properties
Name: umpDS
JNDI名称:jdbc/yypt/ump
Database Type: MS SQL Server
Database Driver: Other
( 2 ) Connection properties
Database name (database name when the client connects): GCCDB
Hostname: 10.10.10.10
Port: 8888
Database username: dbuser
Password: 123456ABc
Confirm Password: 123456ABc
(3)测试数据库连接
驱动程序类名称:com.microsoft.sqlserver.jdbc.SQLServerDriver
URL:jdbc:sqlserver://10.10.10.10:8888;datebaseName=GCCDB;user=dbuser;password=123456ABc
(4)测试配置
(5)完成
无报错则ok
4、报错
(1)测试配置连接报错
Cannot load driver: com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolDataSource
这个报错是你的驱动有问题,因为下载的包里有sqlserver4.jar和sqlserver.jar两个包,这里用sqlserver4.jar,
还要确认ommEnv.cmd文件中WEBLOGIC_CLASSPATH变量结尾添加了sqlserver4.jar的路径;
还要确认你的驱动程序类名称是否正确,为com.microsoft.sqlserver.jdbc.SQLServerDriver,不同的驱动驱动名也是不同的。
(2)点击完成激活更改报错
The DBMS driver exception was: Login failed for user ''. ClientConnectionId:32a26820-3d59-4c00-bb3d-1b0ad91f34b9
This problem is that there is a problem with your data source configuration. Double-check your database name, user, and password for errors. My database name is wrong here, it should be the database name when the client connects: GCCDB.
When starting the instance, I found an error:
javax.naming.NameNotFoundException: Unable to resolve 'jdbc.yypt.ump'. Resolved 'jdbc.yypt'; remaining name 'ump'
Through analysis, we can find out the problem. After confirming that there is no problem with the configuration source in the context file, we can locate the problem in the data source configuration. Check the data source and find that the configured data source is not under the control of Adminserver . After checking the save, the error is reported again. :
The DBMS driver exception was: Login failed for user ''. ClientConnectionId:32a26820-3d59-4c00-bb3d-1b0ad91f34b9
This problem occurs again, and I found that all the information is OK, that is , the problem on the url , which caused this error, the original url :
jdbc:sqlserver://10.10.10.10:8888
change into:
jdbc:sqlserver://10.10.10.10:8888;datebaseName=GCCDB;user=dbuser;password=123456ABc