Problem in establishing DB2 connection in Java with wrong username/password

1.2k Views Asked by At

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

There are 1 best solutions below

2
On

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.