ibmdb / node-ibm_db

IBM DB2 and IBM Informix bindings for node
MIT License
188 stars 151 forks source link

[IBM][CLI Driver] SQL1042C An unexpected system error occurred. SQLSTATE=58004 #992

Closed breno404 closed 2 months ago

breno404 commented 2 months ago

I'm work with a DB2 instance and I connect with this:

I don't provide a .crt file, so I trying connect by node using this connStr "DATABASE=[database];HOSTNAME=[cloud_url];UID=[username];PWD=[password];PORT=[port];PROTOCOL=TCPIP;SECURITY=SSL"

Where am I going wrong?

Note: I have the cli_driver configurated in my computer. image

bimalkjha commented 2 months ago

@breno404 Your connStr is fine, but issue is with clidriver which seems older. It seems your system has multiple copies of db2 client/server installation and GSKit is installed at global path. First, please share complete output of below commands:

db2level
db2cli validate
node -v
npm install ibm_db

Thanks.

bimalkjha commented 2 months ago

SQL1042C error comes, due to problem in loading GSKit library. ibm_db addon binary may be compiled using different clidriver version and at runtime different clidriver is getting used. You should replace your existing clidriver with this one: https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/ntx64_odbc_cli.zip Then try connection. If still fails, share complete output of above commands in previous post. Thanks.

breno404 commented 2 months ago

./db2level image

./db2cli validate image

node -v image

npm install ibm_db command runned into /c/IBMDB2/CLIDRIVER/bin image

breno404 commented 2 months ago

image

bimalkjha commented 2 months ago

@breno404 Your system has clidriver of version 11.5.4.0 which is an old version and the gskit library that comes with this version of clidriver has many security vulnerabilities. Have you set system level environment variable IBM_DB_HOME=C:\IBMDB2\CLIDRIVER ? Please share output of echo %IBM_DB_HOME% from command windows.

Do you see a clidriver directory under ...\node_modules\ibm_db\installer directory after installation of ibm_db? If yes, then you need to set path of this clidriver in PATH and LIB environment variable to be effective. Please share contents of ibm_db\installer directory and full path of ibm_db directory. Thanks.

bimalkjha commented 2 months ago

If you get directory ...\node_modules\ibm_db\installer\clidriver post installation of ibm_db, then run below commands from command windows:

cd ...\node_modules\ibm_db\installer\clidriver\scripts
setenv.bat
db2cli validate
node <your test program>.js

Alternatively, if you download https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/ntx64_odbc_cli.zip, unzip it and replace your existing C:\IBMDB2\CLIDRIVER with this downloaded clidriver, your issue should get fixed. You are getting SQL1042C error due to old version of clidriver. Thanks.