Reputation: 371
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.
Upvotes: 3
Views: 10270
Reputation: 3907
We were getting following error and it was due to AS400 storage get full.
SQL system error. (SQLSTATE 58004, SQLCODE -901)
Upvotes: 0
Reputation: 3980
If you're code works on Linux but fails on Windows and you are using SQLAlchemy, this might also help:
You may be experiencing a known defect that affects some Microsoft Windows configurations.
Use pip show ibm_db to find the "Location:" of your site-packages directory.
Suppose for example, that directory is c:\python\lib\site-packages
Your installation directory will be different, but try to understand the idea.
Then modify your PATH environment variable to append the following directory to the PATH:
c:\python\lib\site-packages\clidriver\bin\amd64.VC12.CRT
(that is, your site-packages path with \clidriver\bin\amd64.VC12.CRT appended to it )
After modifying the PATH, you can retry the python ibm_db database connection.
If you do not have permission to modify the PATH, you can also copy the contents (2 .DLL files) of that amd64.VC12.CRT directory , into another directory that you know will be already on the PATH when python runs.
If you are encrypting your database connections with SSL/TLS, you sometimes also need to add a second directory to the PATH ( ... site-packages\clidriver\bin\icc64 ) .
From https://github.com/ibmdb/python-ibmdb/issues/599
Upvotes: 0