ibmdb / node-ibm_db

IBM DB2 and IBM Informix bindings for node
MIT License
191 stars 149 forks source link

DB2 License issue #897

Closed jishnuraghu closed 1 year ago

jishnuraghu commented 1 year ago

Hi Team,

I understand that this issue is being reported and discussed multiple times in this forum and I had alerady went through it. I'm getting the error SQL1598N An attempt to connect to the database server failed because of a licensing problem. SQLSTATE=42968 while trying to connect to DB2 database. Details from the db2cli is available below.

Question is, the license is not required when we connect from the C# code or Java code using the JDBC drivers. Why is this error coming when we connect from using the node package?

===============================================================================
Client information for the current copy (copy name: C_Users_maxmenu_Development_workspaces_test_poc_ibm-db2-poc_node_modules_ibm_db_installer_clidriver):
===============================================================================

Client Package Type       : IBM Data Server Driver For ODBC and CLI
Client Version (level/bit): DB2 v11.5.6000.7091 (special_13806/64-bit)
Client Platform           : NT 64BIT
Install/Instance Path     : C:\Users\maxmenu\Development\workspaces\test\poc\ibm-db2-poc\node_modules\ibm_db\installer\clidriver

Common App Data Path      : C:\ProgramData\IBM\DB2\C_Users_maxmenu_Development_workspaces_test_poc_ibm-db2-poc_node_modules_ibm_db_installer_clidriver
DB2DSDRIVER_CFG_PATH value: <not-set>
db2dsdriver.cfg Path      : <Common App Data Path>\cfg\db2dsdriver.cfg
DB2CLIINIPATH value       : <not-set>
db2cli.ini Path           : <Common App Data Path>\cfg\db2cli.ini
db2diag.log Path          : <Common App Data Path>\db2diag.log

===============================================================================
List of all IBM Data Server client packages on the current workstation:
===============================================================================

Copyname                                                                                                    Version Package Language Installed-Location
-------------------------------------------------------------------------------
C_Users_maxmenu_Development_workspaces_test_poc_ibm-db2-poc_node_modules_ibm_db_installer_clidriver[C] 11.5.0600 CLI     EN       C:\Users\maxmenu\Development\workspaces\test\poc\ibm-db2-poc\node_modules\ibm_db\installer\clidriver
-------------------------------------------------------------------------------
 CLI: IBM Data Server Driver for ODBC and CLI
-------------------------------------------------------------------------------

===============================================================================
db2dsdriver.cfg schema validation for the entire file:
===============================================================================

Note: The validation utility could not find the configuration file 
db2dsdriver.cfg. The file is searched at
"C:\ProgramData\IBM\DB2\C_Users_maxmenu_Development_workspaces_test_poc_ibm-db2-poc_node_modules_ibm_db_installer_clidriver\cfg\db2dsdriver.cfg".

===============================================================================
db2cli.ini validation for database "dbname:updb.domain.com:12345":
===============================================================================

Note: The validation utility could not find the configuration file db2cli.ini.
The file is searched at
"C:\ProgramData\IBM\DB2\C_Users_maxmenu_Development_workspaces_test_poc_ibm-db2-poc_node_modules_ibm_db_installer_clidriver\cfg\db2cli.ini".

===============================================================================
db2dsdriver.cfg validation for database "dbname:updb.domain.com:12345":
===============================================================================

Note: The validation utility could not find the configuration file
db2dsdriver.cfg. The file is searched at 
"C:\ProgramData\IBM\DB2\C_Users_maxmenu_Development_workspaces_test_poc_ibm-db2-poc_node_modules_ibm_db_installer_clidriver\cfg\db2dsdriver.cfg".

===============================================================================
Connection attempt for database "dbname:updb.domain.com:12345":
===============================================================================

[FAILED]: [IBM][CLI Driver] SQL1598N  An attempt to connect to the database server failed because of a licensing problem.  SQLSTATE=42968

===============================================================================
Error: The validation operation failed.
===============================================================================

===============================================================================
The validation is completed.
===============================================================================
bimalkjha commented 1 year ago

@devuser-2048 The reason is your C# code or Java code is using different driver for which client license is already installed or your C# or Java application is connecting to a different server. You need to pickup the license file used by your C# code and copy under C:\Users\maxmenu\Development\workspaces\agent-view\poc\ibm-db2-poc\node_modules\ibm_db\installer\clidriver\license directory, then it would work for ibm_db too.

More info about db2connect license:

  1. db2connect license is required only if application is connecting to a Db2 for z/OS server or Db2 for IBMi server. No license required for Db2 server installed on a Linux, Unix or Windows system.
  2. If target Db2 server is db2connect activated for unlimited clients, then no client side license required.
  3. There are two types of client side db2connect license: db2jcc_license_cisuz.jar (for Java application) and db2consv*.lic( for non-Java application).
  4. The Java license will not work for ibmdb. So, you need to find db2consv*.lic file and copy it under clidriver\license directory to work. Thanks.
jishnuraghu commented 1 year ago

Thanks for the update @bimalkjha. I'm still getting the error on the license even after adding the db2consv_zs.lic to the location provided. Please find the file below. This is the correct location right? Is there some way to validate the license file contents?

image image

Below is some of the extract from the .lic file

image
bimalkjha commented 1 year ago

@devuser-2048 You can verify the applied license file by using -displaylic option with validate command. You can verify the TCPIP connectivity and check the license info using below command:

db2cli validate -database "dbname:myhost.rocketsoftware.com:446" -user dbuser -passwd dbpass -connect -displaylic

The extract from your .lic file shows the ProductVersion=10.5 i.e. this license file is for a db2 v10.5 driver. The clidriver downloaded at C:\Users\maxmenu\Development\workspaces\test\poc\ibm-db2-poc\node_modules\ibm_db\installer\clidriver is of version 11.5.6.0 which needs a Db2 V11.5 license file. That is why you are still getting SQL1598N error.

You can proceed using either of below method:

  1. Check if you have a Db2Connect V11.5 license file or you can get it from IBM Support.
  2. Install Db2 Client/Server of V10.5 in your system and copy license file under SQLLIB/license directory. Then set system level environment variable IBM_DB_HOME=<full_path_of_db2_v10.5_install_dir> and then run npm install ibm_db. If IBM_DB_HOME is set, then ibm_db will not download the v11.5.6 clidriver but uses the pointed one.

Thanks.

jishnuraghu commented 1 year ago

It's working fine now after installing the drivers and setting the IBM_DB_HOME path. Thank you very much for the help.

Just one more follow up question. If we have to get this run on AWS lambda, then we will require the drivers for the Linux operating system. For v10.5, is it available for download? Could you point to that please? I couldn't find a 10.5 driver here

bimalkjha commented 1 year ago

@devuser-2048 Yes v10.5 driver is available for download. You can download it form here: https://www.ibm.com/support/fixcentral/swg/selectFixes?source=dbluesearch&product=ibm%2FInformation+Management%2FIBM+Data+Server+Client+Packages&release=10.5.*&platform=Linux+64-bit,x86_64&searchtype=fix&fixids=*dsdriver*FP011&function=fixId&parent=ibm/Information%20Management

After download on AWS lambda, you need to untar it, you'll get dsdriver directory. Then cd to dsdriver and run installDSDriver script to install it. Then you can set the IBM_DB_HOME to dsdriver directory. V10.5 driver is out of support, so you do not find it under odbc_cli directory on the link that you shared. Thanks.

jishnuraghu commented 1 year ago

Thank you very much 👍