Search code examples
pythondb2jupyter-notebook

DB2: Getting [IBM][CLI Driver] SQLSTATE=58004 SQLCODE=-1042


I am new to IBM DB2 world and trying to establish a connection with DB2 using Jupyter notebook:

import ibm_db

try:
    ibm_db.pconnect("DATABASE=DB2;HOSTNAME=hostname;PORT=60000;PROTOCOL=TCPIP;UID=user;PWD=password;", "", "")
    print("Connected to DB")
except Exception as e:
    print(e)

But getting:

[IBM][CLI Driver] SQL1042C  An unexpected system error occurred.  SQLSTATE=58004 SQLCODE=-1042

Any suggestions here?

Edit:

Got the solution for the issue. Posting it here so someone might be helped:

Add AUTHENTICATION=SERVER in the ibm_db.pconnect string.


Solution

  • Add AUTHENTICATION=SERVER in the ibm_db.pconnect string.