我在使用错误的用户名/密码建立 DB2 连接时遇到问题。我们有一个应用程序,它在许多系统上的 LAN 上运行,使用位于我的系统以及其他系统上的 DB2 数据库。
首先,我使用此 URL 创建其他系统 DB2 连接:
Connection con = DriverManager.getConnection("jdbc:db2://Rahulkcomputer:50000/XAN4", "rahulk", "dbirs#35");
这将返回正确的 Connection 对象。现在,当我更改 URL 以使用相同的用户名/密码访问系统 DB2 连接时(使用相同的用户名/密码主要用于检查错误处理):
Connection con = DriverManager.getConnection("jdbc:db2://127.0.0.1:50000/XAN4", "rahulk", "dbirs#35");
这次它再次返回 Connection 对象,而不是抛出 SQLException指定错误的用户名/密码(由于我的系统的 DB2 身份验证与 Rahulkcomputer 的系统完全不同)
在获得连接后,我执行此查询来检查正确的用户名,如帖子中所述:
用于连接验证的简单 DB2 查询
SELECT CURRENT SQLID FROM SYSIBM.SYSDUMMY1
(这在两种情况下都会返回“rahulk”)
为什么 DB2 在第二种情况下使用错误的用户创建连接 -名称/密码(此外,当我们关闭 Rahulkcomputer 上 DB2 的所有服务时,即使在第二种情况下我也能获得连接)?
提前致谢。
I have a problem in establishing DB2 connection with wrong user-name/password. We have an application which runs on LAN on many systems using DB2 database located on my system as well as other systems.
Firstly I use this URL to create other system DB2 connection:
Connection con = DriverManager.getConnection("jdbc:db2://Rahulkcomputer:50000/XAN4", "rahulk", "dbirs#35");
this returns proper Connection object. Now when I change the URL to access my system DB2 connection with same user-name/password as (using same user-name/password is intensely done for checking error handling):
Connection con = DriverManager.getConnection("jdbc:db2://127.0.0.1:50000/XAN4", "rahulk", "dbirs#35");
This time it again returns the Connection object instead of throwing an SQLException specifying wrong user-name/password (due to my system's DB2 authentication is totally different from Rahulkcomputer's system)
After getting connection, I execute this query to check proper user name as explained in post:
Simple DB2 Query for connection validation
SELECT CURRENT SQLID FROM SYSIBM.SYSDUMMY1
(this returns "rahulk" in both cases)
Why DB2 created connection in 2nd case with wrong user-name/password (moreover when we close all the services of DB2 on Rahulkcomputer, even then I get the connection in 2nd case)?
Thanks in Advance.
发布评论
评论(1)
您要么使用限制性选项创建数据库,要么从 PUBLIC 撤销对 sysibm 的选择权。您的连接很好,但访问权限不好。 42704 是 DB2 表达“嗯?”的方式,它无法识别 sysibm,因为您无权查看它。
You either created your database with the restrictive option or revoked the select right to sysibm from PUBLIC. The connection you had was fine, the access rights not. 42704 is DB2's way of saying "huh?", it did not recognize sysibm because you had no rights to see it.